Sample: Simple Mail Merge

Having loaded the sample program from the MailMerge_Simple directory, start the program and use the Add method from the ApplicationFields main menu to insert some fields. An XML file is used as a data source which is also used to insert the menu items dynamically.

The following code shows how to insert the fields into TX Text Control:

[C#]
private void InsertMergeField(string Name)
{
    MergeField mergeField = new MergeField();
    mergeField.Name = Name;
    mergeField.Text = "{ " + Name + " }";
    mergeField.ApplicationField.ShowActivated = true;
    mergeField.ApplicationField.DoubledInputPosition = true;

    textControl1.ApplicationFields.Add(mergeField.ApplicationField);
}
[Visual Basic]
Private Sub InsertMergeField(ByVal Name As String)
    Dim mergeField As New MergeField()
    mergeField.Name = Name
    mergeField.Text = "{ " & Name & " }"
    mergeField.ApplicationField.ShowActivated = True
    mergeField.ApplicationField.DoubledInputPosition = True

    textControl1.ApplicationFields.Add(mergeField.ApplicationField)
End Sub

After you created your mail merge template, choose Merge from the MailMerge main menu. The MailMerge component is used to merge the data into the ApplicationFields.

[C#]
mailMerge1.Merge(dsAddresses.Tables[0], true);
[Visual Basic]
mailMerge1.Merge(dsAddresses.Tables(0), true)

Continue with the next sample >>