Use ExecuteWithRegions() - Unique table data on each letter

Hi,

I want to generate multiple letters via mail
merge. In each letter, there is a table of data which is unique to each
letter.

I can see how to use ExecuteWithRegions() to insert a table of data, but this data is the same for each individual letter. I need it to be different for each individual letter.

Is there a way I can achieve this?

Kind Regards, Adam.

Hi Adam,

First, please read the Perform Mail Merge section of our Programmers Guide. Second, download the evaluation version of Aspose.Words and consider the demo projects. It will help you to understand the difference between simple merge and merge with regions and allow to properly prepare the template.

Actually, if you have a number of different data tables and you need to merge each table to a single letter, the easiest way is cloning the template and perform mail merge separately, something like this:

Document template = new Document("Template.doc");
for (int i = 0; i < tableCount; i++)
{
    DataTable table = GetNextTable();
    table.TableName = "DataTable"; // Rename the table as specified in the template.
    Document templateClone = template.Clone();
    templateClone.MailMerge.ExecuteWithRegions(table);
    templateClone.Save(@"Result " + i + ".doc");
}

If you have any further questions, please ask me more.