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

Free Support Forum - aspose.com

How can I define mail merge regions in a document

Hi,
How can I define mail merge regions in a document.
I want to fill specific field in my document with data coming from a database .

I’ve used this code but I’ve problem to define mail merge regions in a document
DataSet dataSet = new DataSet();

//Populate tables and add to the dataset.
dataSet.Tables.Add(GetTestOrder());
dataSet.Tables.Add(GetTestOrderDetails());
dataSet.Tables.Add(GetTestOrderTotals());

//The document should have mail merge regions designated with
//MERGEFIELD TableStart:MyTableName and TableEnd:MyTableName.
Document doc = new Document(Server.Mapath("")+ “\…\Documents\Invoice.doc”);

doc.MailMerge.ExecuteWithRegions(dataSet);

Thank you for help

is Please help, mail merge regions identic of Word field ?

Start with just inserting a merge field in MS Word. This is the way to do “classic” mail merge similar to the one you can have in MS Word.

If you want a portion in your document to grow for each record, such as a table, then you need to use mail merge regions. Merge regions is an “extension” mechanism to improve on the classic mail merge.

To create a mail merge region, you still need to insert a normal merge field in MS Word, but you need to give this field a special name. In fact, you need to insert two merge fields: one to identify the beginning of the merge region and another to identify its end. Of course you need to insert normal “data” merge fields in between the start and end.

To insert the start of a mail merge region, insert a merge field and give name it “TableStart:”. To insert the end of of a merge region, insert a merge field and name it “TableEnd:”.

Also see the Invoice and Employees Report documents and source code in the demo.

Aspose.Word 2.1.3 is released with new demos. For more info see https://docs.aspose.com/words/net/mail-merge-and-reporting/.

Roman,

Thanks for your help.