MailMergeOptions.UseNonMergeFields
MailMergeOptions.UseNonMergeFields property
When true
, specifies that in addition to MERGEFIELD fields, mail merge is performed into some other types of fields and also into “{{fieldName}}” tags.
public bool UseNonMergeFields { get; set; }
Remarks
Normally, mail merge is only performed into MERGEFIELD fields, but several customers had their reporting built using other fields and had many documents created this way. To simplify migration (and because this approach was independently used by several customers) the ability to mail merge into other fields was introduced.
When UseNonMergeFields
is set to true
, Aspose.Words will perform mail merge into the following fields:
MERGEFIELD FieldName
MACROBUTTON NOMACRO FieldName
IF 0 = 0 “{FieldName}” ""
Also, when UseNonMergeFields
is set to true
, Aspose.Words will perform mail merge into text tags “{{fieldName}}”. These are not fields, but just text tags.
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
- class MailMergeOptions
- namespace Wordize.MailMerging
- assembly Wordize