MailMergeOptions.CleanupParagraphsWithPunctuationMarks

MailMergeOptions CleanupParagraphsWithPunctuationMarks property. Gets or sets a value indicating whether paragraphs with punctuation marks are considered as empty and should be removed if the RemoveEmptyParagraphs option is specified.

MailMergeOptions.CleanupParagraphsWithPunctuationMarks property

Gets or sets a value indicating whether paragraphs with punctuation marks are considered as empty and should be removed if the RemoveEmptyParagraphs option is specified.

public bool CleanupParagraphsWithPunctuationMarks { get; set; }

Remarks

The default value is true.

Here is the complete list of cleanable punctuation marks:

  • !
  • ,
  • .
  • :
  • ;
  • ?
  • ¡
  • ¿

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