[Expand]General Information
[Collapse]WinForms Controls
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Map Control
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Product Class Structure
    Supported Formats
   [Expand]Getting Started
   [Expand]RichEditControl Document
    Text Formatting
    Import and Export
   [Expand]Page Layout
    Spell Checking
    Mail Merge
    Restrictions and Protection
    Syntax Highlighting
   [Expand]Visual Elements
    Keyboard Shortcuts
    HTML Tag Support
    [Expand]Text Boxes
    [Expand]Document Elements
    [Expand]Search and Replace
    [Collapse]Mail Merge
      How to: Perform a Mail Merge
      How to: Send the Mail-Merge Document as an E-Mail
    [Expand]Spell Check
    [Expand]Import and Export
    [Expand]User Interface Customization
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[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
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Send the Mail-Merge Document as an E-Mail

The following example describes how to send the mail merge result as an e-mail.

Refer to the How to: Perform a Mail Merge topic for an example on how to create a mail-merge document. Follow the steps below to export the result as a Microsoft® Outlook® mail item.

Expanded Create an Exporter Class

  1. Add a reference to the Microsoft.Office.Interop.Outlook assembly.
  2. Create an exporter class that implements the IUriProvider interface. Declare the class constructor as follows:

  3. Implement the Export method to retrieve the document text in HTML format and convert it into the message body. Subscribe to the RichEditControl.BeforeExport event.

  4. Specify the HtmlDocumentExporterOptions.Encoding property in the BeforeExport event handler.

  5. Implement the interface's IUriProvider.CreateCssUri and IUriProvider.CreateImageUri methods. In this example, the IUriProvider.CreateImageUri method retains the document images and attaches them to the mail message.

Expanded Send the result to the Microsoft® Outlook® application

Declare a new Outlook application object and create a new mail item in the main class. Create a new RichEditMailMessageExporter instance and pass the RichEditControl and the MailItem objects as parameters. Call the Export method.

In this example, the document is sent as a mail item on a "Send Mail" button click.


A full code example is available in the How to export the RichEditControl document into an Outlook mail item repository on GitHub.

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