MailMergeOptions.PreserveUnusedTags

MailMergeOptions PreserveUnusedTags property. Gets or sets a value indicating whether the unused mustache tags should be preserved.

MailMergeOptions.PreserveUnusedTags property

Gets or sets a value indicating whether the unused “mustache” tags should be preserved.

public bool PreserveUnusedTags { get; set; }

Remarks

The default value is false.

Examples

Shows how to use mustache syntax instead of regular merge field in the template.

string[] names = new string[] { "FirstName", "SecondName", "Position" };
string[] values = new string[] { "James", "Bond", "" };

MailMergeOptions mailMergeOptions = new MailMergeOptions();
mailMergeOptions.UseNonMergeFields = true;
mailMergeOptions.CleanupParagraphsWithPunctuationMarks = true;
mailMergeOptions.PreserveUnusedTags = true;
mailMergeOptions.CleanupOptions = MailMergeCleanupOptions.RemoveEmptyParagraphs;

MailMerger.Execute(MyDir + "MailMergeTemplateMustache.docx",
    ArtifactsDir + "MailMergeOptions.UseNonMergeFields.docx",
    SaveFormat.Docx,
    names,
    values,
    mailMergeOptions);

See Also