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

Free Support Forum - aspose.com

Have to reinstantiate the Document object to re-run MailMerge.ExecuteWithRegions?

Hi, we are trying to merge multiple documents from a template by updating values in a table of the DataSet we pass to Document.MailMerge.ExecuteWithRegions. If we don’t reinstantiage the template Document object before each call to that method, we get the same content in each document. Is this the intended behavior?

Thanks for your request. I think that you can Clone original document. For example see the following code:

// Open template document
Document tempDocument = new Document("in.doc");
// Generate documents
int docIndex = 0;
foreach (DataRow row in table.Rows)
    // Clone template document
    Document tempDoc = (Document)tempDocument.Clone(true);
    // generate new name
    string outDocName = string.Format("out_{0}.doc", docIndex);
    // Execute mail merge
    // Save document

Hope this helps.
Best regards.