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

Free Support Forum - aspose.com

Create MailMerge document

Goodmorning,

Please could you advice?

We have been trying to create a MS-Word document containing mailmerge fields. We have been using the code below.

Aspose.Words.Document doc = new Aspose.Words.Document();
Aspose.Words.DocumentBuilder bld = new Aspose.Words.DocumentBuilder(doc);
bld.Writeln("my document, par 1");
bld.Write("Name: ");
bld.InsertField(@"MERGEFIELD Name \* MERGEFORMAT", "John Doe");
bld.Writeln("");
bld.Write("Address: ");
bld.InsertField(@"MERGEFIELD Address \* MERGEFORMAT", "Street 1");
bld.Writeln("");
bld.Writeln("my document, par 2");
bld.Writeln("greetings,");
doc.Save(@"c:\temp\letter.doc");

Now we wish to achieve that when we open the document with MS-Word the fields will be shown in the "Insert Merge Field" dropdown. Which is default when one creates a mailmerge document in MS-Word.

Is there a way to accomplish this? It's pretty important to us. In plain English, we wish to create a MS-Word document where we can select mailmerge fields from the "Insert Mailmerge Field" dropdown.

Kind regards,

Jan Stolk
The Netherlands.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Merge fields you can select from “Insert Merge Filed” dropdown are selected from MailMerge datasource. Unfortunately you can’t specify MailMerge datasource using Aspose.Words. I think that you can just copy/paste the existing MergeFileds in document.

Best regards.