In version X14 (24.0), the MailMerge class will be improved with new features and enhancements. The MailMerge class is a .NET component that can be used to effortlessly merge template documents with database content in all .NET projects, such as ASP.NET web applications, web services or Windows services.

Merge with JSON Data

The new method MergeJsonData merges a JSON string into reporting templates. The JSON data can contain either a single object or an array of equally structured objects (JSON array). The following code snippet merges one merge field (test) with JSON data:

MailMerge mailMerge = new MailMerge();
mailMerge.TextComponent = textControl1;
string json = "{ \"test\":\"TextTest\" }";
mailMerge.MergeJsonData(json);
view raw test.cs hosted with ❤ by GitHub

MailMerge Events

The Text Control Reporting Framework is a very flexible framework to merge data into MS Word compatible templates. With a single line of code, the merge process can be started to generate Adobe PDF or MS Word documents.

In order to manipulate the merge process and to inject custom logic, each merge element such as merge fields and merge blocks fire events. These events return the merged field, information about the location of a field and provide access to data that is used to merge the document.

In these events, a DataRowAdapter provides access to the DataTableAdapter which gains access to the child table names, column names, the DataTable, the data rows and the table name. Additionally, the new FieldMergedEventArgs property MergeBlockName returns the block name in case the field is embedded in a merge block. The NestingDepth property returns the nesting level of the field.

These new properties allow a very flexible interaction with the merge process.

MailMerge improvements in X14: Event arguments and JSON data sources

Stay tuned for more details!