Skip to main content

Export to MailMessage

  • 2 minutes to read

This document details the export of a document to an email message represented by an instance of the MailMessage class.

Note that exporting a document to an email message and sending the resulting message to recipients can only be performed at run time. The resulting MailMessage instance contains an HTML representation of the report contents optimized for transmission by email. You can then use the mail functionality of the .NET Framework to programmatically send the generated message to an arbitrary number of recipients using the required email settings.

The options that can be specified for a document exported to an email message are stored in an MailMessageExportOptions object, and can be accessed using a report’s ExportOptions.MailMessage property. The MailMessageExportOptions class extends the HtmlExportOptionsBase class and provides access to a set of options common to all HTML-based export formats.

Among these options, the HtmlExportOptionsBase.ExportMode property determines the way in which a document is exported to HTML. For instance, it may be exported to a single file (with a single page header at the beginning and a single page footer at the end), or it may be exported page-by-page to either a single file or different files.

The HtmlExportOptionsBase.TableLayout property determines whether or not to use the table layout in the resulting HTML markup. If this property is set to false, the non-table layout is used instead. The table layout is recommended, as it uses a more compact and efficient markup.

The HtmlExportOptionsBase.ExportWatermarks property specifies whether or not to maintain the existing text and image watermarks of a report in the HTML markup. The following image illustrates the corresponding option in the HTML Export Options dialog.

html-export-options-watermarks

Only report controls that do not intersect each other can be correctly exported to HTML using the table layout.
Intersecting report controls may completely break the resulting mail message layout.

To make sure that your report layout will be preserved in RTF, enable the report’s DesignerOptions.ShowExportWarnings property at design time, and ensure there are no controls colored in red, which marks intersecting controls.

ShowExportWarnings

If you need to export a report that contains intersecting controls to an email message, use the non-table layout.