officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-document-dot-mailmerge-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-mailmergeoptions-system-dot-string-devexpress-dot-xtrarichedit-dot-documentformat-x29.md
Using file paths sourced from untrusted input may expose unauthorized files or allow unintended file access. Always validate and normalize all external paths to prevent path manipulation.
Merges data to the current document and saves the result to a file in the specified format. Allows you to set mail merge options.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
void MailMerge(
MailMergeOptions options,
string fileName,
DocumentFormat format
)
Sub MailMerge(
options As MailMergeOptions,
fileName As String,
format As DocumentFormat
)
| Name | Type | Description |
|---|---|---|
| options | MailMergeOptions |
An object that contains options for the current merge.
| | fileName | String |
A name of the file to which the merged document is saved.
| | format | DocumentFormat |
An enumeration member that indicates the destination format.
|
The MailMerge method merges the current document with records retrieved from the MailMergeOptions.DataSource property specified by the options parameter, and saves the merged document to a file.
The MailMerge method results in the Document.CalculateDocumentVariable event being fired for the Document object.
The following code snippets (auto-collected from DevExpress Examples) contain references to the MailMerge(MailMergeOptions, String, DocumentFormat) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-richedit-control-mail-merge/CS/MailMerge/Form1.cs#L56
// Export a mail-merged document in a new file
richEditControl1.Document.MailMerge(myMergeOptions, fileDialog.FileName, DocumentFormat.OpenXml);
System.Diagnostics.Process.Start(fileDialog.FileName);
winforms-richedit-use-images-in-mail-merge/CS/Form1.cs#L46
richEditControl1.Document.MailMerge(options, fileName, DocumentFormat.Rtf);
word-document-api-use-docvariable-fields/CS/Program.cs#L37
// Mail-merge the document
document.MailMerge(myMergeOptions, "Result.docx", DocumentFormat.OpenXml);
var p = new Process();
word-processing-use-images-in-richedit-mail-merge/CS/Program.cs#L41
richEditDocumentServer.Document.MailMerge(options, fileName, DocumentFormat.Rtf);
winforms-richedit-control-mail-merge/VB/MailMerge/Form1.vb#L51
'Export the mail-merged document in a new file
richEditControl1.Document.MailMerge(myMergeOptions, fileDialog.FileName, DocumentFormat.OpenXml)
System.Diagnostics.Process.Start(fileDialog.FileName)
winforms-richedit-use-images-in-mail-merge/VB/Form1.vb#L38
Dim fileName As String = System.IO.Directory.GetCurrentDirectory() & "MailMergeResult.rtf"
richEditControl1.Document.MailMerge(options, fileName, DocumentFormat.Rtf)
Dim processor As New Process()
word-document-api-use-docvariable-fields/VB/Program.vb#L31
' Mail-merge the document
document.MailMerge(myMergeOptions, "Result.docx", DocumentFormat.OpenXml)
Dim processor As New Process()
word-processing-use-images-in-richedit-mail-merge/VB/Program.vb#L35
richEditDocumentServer.Document.MailMerge(options, fileName, DocumentFormat.Rtf)
See Also