DocumentMailMerge Property
Returns a MailMerge object that represents the mail merge functionality for the document.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.12
public MailMerge MailMerge { get; }

Property Value

Type: MailMerge
Executes mail merge from an ADO.NET DataTable.
Document doc = new Document(MyDir + "MailMerge.ExecuteDataTable.doc");

// This example creates a table, but you would normally load table from a database. 
DataTable table = new DataTable("Test");
table.Rows.Add(new object[] { "Thomas Hardy", "120 Hanover Sq., London" });
table.Rows.Add(new object[] { "Paolo Accorti", "Via Monte Bianco 34, Torino" });

// Field values from the table are inserted into the mail merge fields found in the document.

doc.Save(ArtifactsDir + "MailMerge.ExecuteDataTable.doc");

// Open a fresh copy of our document to perform another mail merge.
doc = new Document(MyDir + "MailMerge.ExecuteDataTable.doc");

// We can also source values for a mail merge from a single row in the table

doc.Save(ArtifactsDir + "MailMerge.ExecuteDataTable.OneRow.doc");
See Also