160 likes | 298 Views
Mail Merge in WordProcessingML. Article by Sheela E.N Sonata Software Limite GI1 10 張筱懿. Introduction. This article briefly explains the concept of Mail Merge and how this information is stored in WordProcessingML.
E N D
Mail Merge in WordProcessingML Article by Sheela E.N Sonata Software Limite GI1 10 張筱懿
Introduction • This article briefly explains the concept of Mail Merge and how this information is stored in WordProcessingML. • A mail merge is a word processing feature that allows in creating common letters, mailing labels, envelopes, or cataloging documents to a group of people as stored in a database.
We use mail merge when we want to create a set of documents that are essentially in a template format but only in a single place contains unique information. • For example, in a letter that announces a new product to all its customers, the company logo and the text about the product is common and will appear in each letter, while the customer address and greeting line will be different in each letter.
The two key parts of the mail merge process are • Connecting to an external data source • Populating mail merge fields with external data
Connecting to an external data source • The connection details of the external data source are mentioned in the settings.xml file as
<w:mailMerge> • The <w:mailMerge> element specifies the following information of the hosting application to connect to an external data source – • w:mainDocumentType — specifies the type of the mail merge. The possible types are • formLetters. • Email • Envelopes • Fax • mailingLabels • Catalog • w:query – specifies the table to be queried.
w:dataSource — specifies the link to the external data source. The details are stored in document setting part relationship. • w:viewMergedData — specifies that the merged document shall display the data from the specified external data source where merge fields have been inserted. • w:activeRecord — specifies which record within the data source should be displayed. • w:odso — The Office Data Source Object (odso) settings is optional details which specifies a group of additional settings for the mail merge information which comprises an extension to the standard settings stored with a mail merge.
The Office Data Source Object Settings also contains a link to another part (mailMergeRecipientData) which contains details about all of the inclusion/exclusion data for the contents of the specified mail merge data source and is represented as
Recipient data part • The details of the record inclusion/exclusion in mail merge recipient data part are stored as
The <w:recipientData> element specifies the following details for the inclusion/exclusion of records within mail merged document. • w:column — specifies the column on which the filter has applied based on the value of the column (like where clause on that column). • w:uniqueTag — specifies the contents of a given record within the specified external data source, in the column containing unique data for every record within the external data source for inclusion/exclusion of records for mail merge. The value specifies that this should be the base64-encoded value of the unique tag value as specified by the data source. This element is used along with <w:column> element.
w:active — specifies whether the record to be shown on not. The default value is 1 which indicates the record is included for the mail merge. • If this part is not present, it indicates that all the records within the data source are included for the mail merge.
Main document part • In the main document part (document.xml by default), the merge fields are populated by extracting data from external data source and the same is represented as
In the above XML snippet, the merge field ‘FirstName’ is inserted in a WordprocessingML document which connects to the external data source. • When the mail merge takes place, the data from the FirstName column will be populated into the field FirstName (<w:fldSimple w:instr="MERGEFIELD FirstName">) within the merged WordprocessingML document.
Result • The word document containing mail merge field place holders is illustrated as