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
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();
data.Columns.Add("FirstName");
data.Columns.Add("LastName");
data.Columns.Add("City");
data.Columns.Add("Company");
// add dummy data
data.Rows.Add(new object[] { "Den", "Smith", "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
    temp.MailMerge.Execute(row);
    // Save document
    temp.Save(string.Format(@"Test014\out_{0}.doc", counter));
    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?

Thanks

Hi
Thanks for your request. You can find such example in the documentation. Please see the following link:
https://reference.aspose.com/words/net/aspose.words.mailmerging/mailmerge/execute/
Best regards,