We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Outputing multiple documents clarification

So in the Dinner Invitation demo I expect that there are multiple documents that are created. Does the MailMerge.Execute method have to be called for each new row to produce a new document?
This message was posted using Page2Forum from Simple Mail Merge Explained - Aspose.Words for .NET and Java

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Yes, you should execute mail merge for each record in your data source. Please see the following code:

//Create dummy datasource

DataTable data = new DataTable();





//add dummy data

data.Rows.Add(new object[] { "Den", "Smith", "<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />London", "Apple" });

data.Rows.Add(new object[] { "Steve", "Martin", "Berlin", "Stern" });

data.Rows.Add(new object[] { "Nina", "Burn", "Tallin", "IBM" });

//Open template document

Document doc = new Document(@"Test014\in.doc");

int counter = 0;

//Loop though all record in our datasource

foreach (DataRow row in data.Rows)


//Clone template

Document temp = (Document)doc.Clone(true);

//Execute mail merge


//Save document

temp.Save(string.Format(@"Test014\out_{0}.doc", counter));



Hope this helps.

Best regards.

Thanks for the feedback. The example is very helpful.

I noticed that the API’s MaillMerge.Execute also accepts System.Data.DataTables. Could you provide a little sample using DataTables?


Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. You can find such example in the documentation. Please see the following link:


Best regards,