MailMerge Class

Mail Merge Settings.When the object is serialized out as xml, its qualified name is w:mailMerge.

Inheritance Hierarchy


Namespace:  DocumentFormat.OpenXml.Wordprocessing
Assembly:  DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)


<ChildElementInfoAttribute(GetType(DoNotSuppressBlankLines))> _
<ChildElementInfoAttribute(GetType(DataSourceObject))> _
<ChildElementInfoAttribute(GetType(MainDocumentType))> _
<ChildElementInfoAttribute(GetType(LinkToQuery))> _
<ChildElementInfoAttribute(GetType(DataType))> _
<ChildElementInfoAttribute(GetType(ConnectString))> _
<ChildElementInfoAttribute(GetType(Query))> _
<ChildElementInfoAttribute(GetType(DataSourceReference))> _
<ChildElementInfoAttribute(GetType(HeaderSource))> _
<ChildElementInfoAttribute(GetType(Destination))> _
<ChildElementInfoAttribute(GetType(AddressFieldName))> _
<ChildElementInfoAttribute(GetType(MailSubject))> _
<ChildElementInfoAttribute(GetType(MailAsAttachment))> _
<ChildElementInfoAttribute(GetType(ViewMergedData))> _
<ChildElementInfoAttribute(GetType(ActiveRecord))> _
<ChildElementInfoAttribute(GetType(CheckErrors))> _
Public Class MailMerge _
    Inherits OpenXmlCompositeElement
Dim instance As MailMerge
public class MailMerge : OpenXmlCompositeElement


The following table lists the possible child types:

  • MainDocumentType <w:mainDocumentType>

  • LinkToQuery <w:linkToQuery>

  • DataType <w:dataType>

  • ConnectString <w:connectString>

  • Query <w:query>

  • DataSourceReference <w:dataSource>

  • HeaderSource <w:headerSource>

  • DoNotSuppressBlankLines <w:doNotSuppressBlankLines>

  • Destination <w:destination>

  • AddressFieldName <w:addressFieldName>

  • MailSubject <w:mailSubject>

  • MailAsAttachment <w:mailAsAttachment>

  • ViewMergedData <w:viewMergedData>

  • ActiveRecord <w:activeRecord>

  • CheckErrors <w:checkErrors>

  • DataSourceObject <w:odso>

[ISO/IEC 29500-1 1st Edition]

17.14.20 mailMerge (Mail Merge Settings)

This element specifies all of the mail merge information for a document that has been connected to an external data source as part of a mail merge operation.

The document which contains this mail merge data can be of one of two types:

  • A source document, the document which contains all of the information for the mail merge, and is used in conjunction with an application to connect to an external data source and create one document for each record in that data source.

  • A merged document, a document which contains all of the information for the mail merge as well as a reference to a single specific record which shall be used to populate the values of all of the merge fields in that document.

The information in this element shall contain all data needed to connect to a data source and populate any merge fields in the document with data from that data source.

[Example: Consider the following WordprocessingML fragment for a document which is part of a mail merge:

<w:dataType w:val="spreadsheet" />
<w:query w:val="SELECT * FROM `Sheet1$`" />
<w:dataSource r:id="rId1" />

Here, the dataType (§17.14.10) and dataSource (§17.14.9) elements specify that the given document must be connected to the external data source referenced by the relationship whose id value is equal to rId1. While connected to the external data source, the document together with a hosting application can extract data from the external data source as specified by thequery (§17.14.26) element. end example]

Parent Elements

settings (§

Child Elements


activeRecord (Record Currently Displayed In Merged Document)


addressFieldName (Column Containing E-mail Address)


checkErrors (Mail Merge Error Reporting Setting)


connectString (Data Source Connection String)


dataSource (Data Source File Path)


dataType (Data Source Type)


destination (Merged Document Destination)


doNotSuppressBlankLines (Remove Blank Lines from Merged Documents)


headerSource (Header Definition File Path)


linkToQuery (Query Contains Link to External Query File)


mailAsAttachment (Merged Document To E-Mail Attachment)


mailSubject (Merged E-mail or Fax Subject Line)


mainDocumentType (Source Document Type)


odso (Office Data Source Object Settings)


query (Query For Data Source Records To Merge)


viewMergedData (View Merged Data Within Document)


[Note: The W3C XML Schema definition of this element’s content model (CT_MailMerge) is located in §A.1. end note]

© ISO/IEC29500: 2008.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also


MailMerge Members

DocumentFormat.OpenXml.Wordprocessing Namespace