If Fields

The If field compares two values and then inserts the text appropriate to the result of the comparison.

When used in a mail merge main document, the If field can examine information in the merged data records, such as postal codes or account numbers.

Following example demonstrates how to perform a conditional mail merge by importing data from an instance of an anonymous type.

If Fields Screenshot
Upload your file (Drag file here)
using GemBox.Document;

class Program
{
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        DocumentModel document = DocumentModel.Load("%InputFileName%");

        var customer = new { Gender = "M", CustomerName = "John", Surname = "Doe" };

        document.MailMerge.Execute(customer);

        document.Save("If Fields.%OutputFileType%");
    }
}
Imports GemBox.Document

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Dim document As DocumentModel = DocumentModel.Load("%InputFileName%")

        Dim customer = New With {.Gender = "M", .CustomerName = "John", .Surname = "Doe"}

        document.MailMerge.Execute(customer)

        document.Save("If Fields.%OutputFileType%")

    End Sub

End Module

Check next example or download examples from GitHub.