Mail Merge Form Fields in Python

Aspose.Words - Mail Merge Form Fields

Python Code

## Load the template document.

doc = self.Document(self.dataDir + "Template.doc")
\# Setup mail merge event handler to do the custom work.
c = HandleMergeField()
proxy = jpype.JProxy("com.aspose.words.IFieldMergingCallback", inst=c)
\# This is the data for mail merge.
fieldNames = ["RecipientName", "SenderName", "FaxNumber", "PhoneNumber",
    "Subject", "Body", "Urgent", "ForReview", "PleaseComment"]
fieldValues = ["Josh", "Jenny", "123456789", "", "Hello",
    "Test message 1", True, False, True]
\# Execute the mail merge.
doc.getMailMerge().execute(fieldNames, fieldValues)
\# Save the finished document. + "Template Out.doc")

Download Running Code

Download Mail Merge Form Fields (Aspose.Words) from any of the below mentioned social coding sites: