Question about mail merge

Hi,
When i am merging data from database to word. If i have a list to be merged. I mean i dont know how many records will be there. I need to merge those records in the word document. how to do this. Please let me know as soon as possible.
Thanks,
ravi

Hi
Thanks for your request. I think that you can try to use the ExecuteWithRegions method. See the following link to learn more about it.
https://docs.aspose.com/words/net/types-of-mail-merge-operations/
I hope that this will help you.
Please let me know if you would like to know something else.
Best regards.

Hi,
Hi,
Just getting through your message regarding mail merge with regions. How to place the table names in the document. Dont mind and give me a sample code for this.
thanks

Hi
Thanks for your request. You should build your table in the word document like the following.

Header Header Header Header Header
«TableStart:table»«field1» «field2» «field3» «field4» «field5»«TableEnd:table»

Use the following code and you will get the following result.

// create datatable
DataTable table = new DataTable("table");
table.Columns.Add("field1");
table.Columns.Add("field2");
table.Columns.Add("field3");
table.Columns.Add("field4");
table.Columns.Add("field5");
// add some data 
for (int i = 0; i < 5; i++)
{
    DataRow row = table.NewRow();
    row[0] = "test";
    row[1] = "test";
    row[2] = "test";
    row[3] = "test";
    row[4] = "test";
    table.Rows.Add(row);
}
// open template document
Document doc = new Document(@"in.doc");
// execute mailmerge
doc.MailMerge.ExecuteWithRegions(table);
// save result.
doc.Save(@"out.doc");

Result

Header Header Header Header Header
test test test test test
test test test test test
test test test test test
test test test test test
test test test test test

I hope that this will help you.
Best regards.