Log In
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Collapse]Document Server
  Product Information
 [Expand]Redistribution and Deployment
 [Expand]Spreadsheet Document Server
 [Expand]XL Export Library
 [Expand]Rich Edit Document Server
 [Collapse]Snap Document Server
   Getting Started
    How to: Insert Data
    How to: Format Data
    How to: Group Data
    How to: Filter Data
    How to: Sort Data
    How to: Create Parameter
    How to: Create Calculated Field
    How to: Create Barcode
    How to: Create Sparkline
    How to: Create Check Box
    How to: Generate Master-Detail Mail Merge Documents
 [Expand]PDF Document Processor
 [Expand]Compression Library
 [Expand]Bar Code Library
 [Expand]Unit Conversion Library
 [Expand]API Reference
[Expand]Report Server
[Expand]eXpressApp Framework
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Generate Master-Detail Mail Merge Documents


The Universal Subscription or an additional Document Server Subscription is required to use this example in production code. Please refer to the DevExpress Subscription page for pricing information.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E5078.

The following code uses the Snap API to generate a mail-merge report in the context of the DevExpress Document Server.

It is a console application that creates a document and then exports it to an RTF file.

To use the SnapDocumentServer, the project requires references to the following assemblies:

  • DevExpress.Data.v17.2.dll
  • DevExpress.Docs.v17.2.dll
  • DevExpress.Office.v17.2.Core.dll
  • DevExpress.RichEdit.v17.2.Core.dll
  • DevExpress.Snap.v17.2.Core.dll

To perform mail merge, the application requires a template - a file in the native .SNX format which contains the document layout, specific fields and data source information. The template file must be created beforehand using the Snap Design Surface. For an example of template creation, review the Lesson 3 - Create a Mail Merge Report.

The code handles the SnapDocumentServer.SnapMailMergeRecordStarted and SnapDocumentServer.SnapMailMergeRecordFinished events to make adjustments to the merged document created for the particular data record.

The server loads a mail merge template using the RichEditDocumentServer.LoadDocument method. Subsequently, the code assigns the data source by specifying the IDataSourceOwner.DataSource property. The mail merge operation is performed by calling the SnapDocumentServer.SnapMailMerge method.

How would you rate this topic?​​​​​​​