In this article you will learn that how to populate mail merge or mustache template with data in various languages. You can download an SDK of your favorite language and start programming in a smartest way. The SDKs are available in Java, .NET, PHP, Ruby, Python, NodeJS, Swift, Android and Go languages. This API represents a controller for executing the mail merge. Description of some important parameters of the API is given below:
Merge with regions or not. False by default.
Flag 'withRegions' can be omitted, in this case, a simple mail merge will be executed. If the flag is present and value is 'true' - mail merge with regions will be executed.
|mailMergeDataFile||If mailMergeDataFile parameter exists, the data is taken from the server path (the parameter must contain the full path to the server file). However, if the mailMergeDataFile parameter is omitted, the data is expected in the requested content.|
If the cleanup parameter is omitted, cleanup options will be None.
|useWholeParagraphAsRegion||Specifies a value indicating whether paragraphs with TableStart or TableEnd field should be fully included in the mail merge region or particular range between TableStart and TableEnd fields. The default value is true.|
The cleanup options parameter can contain a list of values from below, separated by ",":
|None||Without any cleanup.|
|EmptyParagraphs||Specifies whether paragraphs that contained mail merge fields with no data should be removed from the document.|
|UnusedRegions||Specifies whether unused mail merge regions should be removed from the document.|
|UnusedFields||Specifies whether unused merge fields should be removed from the document.|
|ContainingFields||Specifies whether fields that contain merge fields (for example, IFs) should be removed from the document if the nested merge fields are removed.|
|RemoveTitleRow||Removes title row of the table if this table doesn't contain any rows except title row. It does not remove title rows in nested tables.|
|RemoveTitleRowInInnerTables||Enable "RemoveTitleRow " for nested tables.|
|RemoveStaticFields||Specifies whether static fields should be removed from the document. Static fields are fields, which results remain the same upon any document change. Fields, which do not store their results in a document and are calculated on the fly (like Aspose.Words.Fields.FieldType.FieldListNum, Aspose.Words.Fields.FieldType.FieldSymbol, etc.) are not considered to be static.|
Swagger UI lets you call this REST API directly from the browser. The description of the API and its parameters is also given there.
Case 1: MailMerge Template
Input Document: SampleMailMergeTemplate.docx
Mail Merge Data: SampleMailMergeTemplateData.txt
Output Document: TestPostDocumentExecuteMailMerge.docx
Case 2: Mustache Template
Input Document: TestExecuteTemplate.doc
Mail Merge Data: TestExecuteTemplateData.txt
Output Document: TestPostExecuteTemplate.docx
Using an SDK (API client) is the quickest way for a developer to speed up the development. An SDK takes care of a lot of low-level details of making requests and handling responses and lets you focus on writing code specific to your particular project. Check out our GitHub repository for a complete list of Aspose.Words SDKs along with working examples, to get you started in no time. Please check Available SDKs article to learn how to add an SDK to your project.