Work with mail merge document type and mail merge with region using Java

Hi Support,

Hope that everything is ok for you regarding Covid-19.
My problem question is the following :
In my application, I need to know the difference between mailmerge document that have the word property MailMerge.MainDocumentType equal to wdFormLetters or equal to wdCatalog (or wdDirectory) because, in the first case, I will used
dstDoc.getMailMerge().execute( lstKey, lstVal )
and in the second case I will used

Thank you for your help.



With MailMerge.Execute method, you can performs mail merge from a DataRow, DataTable, and for a single record. With MailMerge.ExecuteWithRegions, you can perform mail merge from a DataSet, DataTable, a custom data source. The answer of your query is well explained in the following article.
About Mail Merge

We suggest you please use the mail merge as suggested in the above article. Regarding mail merge type, you can use Document.MailMergeSettings property to get or set the object that contains all of the mail merge information for a document.

You can use this object to specify a mail merge data source for a document and this information (along with the available data fields) will appear in Microsoft Word when the user opens this document. Or you can use this object to query mail merge settings that the user has specified in Microsoft Word for this document.

Simple example of mail merge setting is to use data source like CSV or TXT with mail merge template. Please check the attached image for MailMergeSettings.

mail merge setting.png (10.2 KB)

Hi Tahir,

Thank you for this information.
Have a good day.


Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.