[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Grid View
  [Expand]Tree List
  [Expand]Card View
  [Expand]Reporting
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Spreadsheet
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Getting Started
   [Collapse]Concepts
     ASPxRichEdit Control
    [Expand]Document
     Supported Document Formats and Printing
     Import and Export
     Formatting Characters
     Formatting Paragraphs
     AutoCorrect
    [Expand]Fields
     Mail Merge
     Simple View
     Table of Contents
     Restrictions
     Spell Checking
    [Expand]Client API
    [Expand]Built-in Dialogs
     Adaptivity
     HTML Tag Interpretation
     Keyboard Shortcuts
   [Expand]Examples
  [Expand]Scheduler
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Gauges
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Mail Merge

The Mail Merge retrieves data from a bound data source and fills in the fields in a document template. This feature is useful for letters, catalogs, mailing labels and for personalizing any kind of a document.

Performing a mail merge in a rich text document requires the following two steps.

  • Specify the RichEdit's data source by using the ASPxDataWebControl.DataSourceID (or ASPxDataWebControlBase.DataSource) property.

  • Create a template by inserting MERGEFIELD fields. The field names refer to data column names of a specified data source.

    Note

    The MERGEFIELD field only enables the substitution of plain text. Formatted text that is inserted from a data source into a merge field will not be recognized and properly parsed. To insert formatted content, use the DOCVARIABLE field.

When an application runs with the mail merge data source attached to the ASPxRichEdit control, ribbon commands of the Mail Merge tab allow end-users to visually insert mail merge fields (placeholders for the dynamic content) from the bound data source, navigate through data source records and preview merged data.

For instance, an end-user can select the field to insert by clicking the Insert Merge Field button in the ribbon. The invoked dialog containing available filed names is shown.

End-users can also initiate the mail merge by clicking the Mail Merge ribbon button in the Finish group. The resulting merged document can be generated for all or specific data source records, and saved to a server folder or downloaded by a client.

 

To perform a mail merge programmatically, call the ASPxRichEdit.MailMerge method. You can pass required parameters by creating the MailMergeOptions instance using the ASPxRichEdit.CreateMailMergeOptions method and specifying it in the MailMerge call. The resulting document can be sent to another ASPxRichEdit control or to the RichEditDocumentServer instance for further processing, can be saved to a file or a Stream object.

Is this topic helpful?​​​​​​​