Wiki

Clone wiki

Aspose for OpenXML / Execute Simple Mail Merge

In order to prepare your template to perform a simple mail merge (without regions, similar to the classic mail merge available in Microsoft Word) you should just insert one or more merge fields in the places you want to be populated with data from the data source.

#!c#

 // Open an existing document.
            Document doc = new Document("Merge Field.doc");

            // Fill the fields in the document with user data.
            doc.MailMerge.Execute(
                new string[] { "Name", "City"},
                new object[] { "Zeeshan", "Islamabad" });

            // Send the document in Word format to the client browser with an option to save to disk or open inside the current browser.
            doc.Save("MailMerge.ExecuteArray Out.doc");

Download

Updated