The MailMerge class is a .NET component that can be used to effortlessly merge template documents with database content in .NET projects, such as ASP.NET web applications, web services or Windows services. The MailMerge class can be found in the TXTextControl.DocumentServer namespace. It is inherited from the System.ComponentModel.Component class. The following describes only the properties and methods defined through the MailMerge class. For a list of properties, methods and events inherited from the System.ComponentModel.Component class see the .NET Framework reference.

Syntax

public class MailMerge : Component
Public Class MailMerge
  Inherits Component

Introduced: 14.0.

Constructors

Constructor Description
MailMerge Initializes a new instance of the MailMerge class.

Events

Event Description
BarcodeMerged Occurs when a barcode has been merged successfully.
BlockMerging Occurs when a merge block is about to be merged.
BlockRowMerged Occurs when a merge block row has been merged successfully.
ChartMerged Occurs when a chart has been merged successfully.
DataRowMerged Occurs when a data row has been merged successfully.
FieldMerged Occurs when a field has been merged.
ImageFieldMerged Occurs when an image field, i.e., a merge field whose name is prefixed with "image:" has been merged.
ImageMerged Occurs when an image has been merged successfully.
IncludeTextMerging Occurs when an IncludeText field has been merged.

Methods

Method Description
GetBlockFieldNames Returns the names of all merge fields inside the merge block with the specified name.
GetBlockNames Lists the names of all merge blocks contained in the currently loaded template.
LoadTemplate Loads a template from a file that is used for the merge process.
LoadTemplateFromMemory Loads a template from memory that is used for the merge process.
Merge Merges given data into the loaded document template.
MergeBlocks Merges all repeating blocks that are contained in the loaded template with the System.Data.DataTable instances contained in the given System.Data.DataSet.
MergeJsonData Merges data given as a JSON string into a document template.
MergeObject Merges a single instance of an arbitrary type into the loaded document template.
MergeObjects Merges a collection of type System.Collections.IEnumerable containing objects of any type or instances of type System.Collections.Generic.Dictionary with string keys into the loaded document template.
Print Prints the merged document.
SaveDocument Saves the merged document to a file.
SaveDocumentToMemory Saves the merged document.

Properties

Property Description
MergeBlockNamePrefix A static property returning the internal merge block name prefix "txmb_".
RemoveEmptyBlocks Specifies whether the content of empty merge blocks should be removed from the template or not.
RemoveEmptyFields Specifies whether empty fields should be removed from the template or not.
RemoveEmptyImages Specifies whether images which don't have merge data should be removed from the template or not.
RemoveEmptyLines Specifies whether text lines which are empty after merging should be removed from the template or not.
RemoveTrailingWhitespace Specifies whether trailing whitespace should be removed before saving a document.
ReportDataSourceConfig Specifies the Report Data Source Configuration as an XML string.
ReportDataSourceConfigFile Gets or sets the file path of a Report Data Source Configuration file (*.rdsc) which has been created with TX Text Control Words.
SearchPath Specifies a directory name where sub-templates and images (for image merging) should be searched.
TemplateFile Specifies the template file path.
TextComponent Gets or sets the TextComponent object which is associated with the MailMerge component.
UseTemplateFormat Specifies whether the template page size and margins should be used or not.