TX Text Control .NET Server

Mail Merge

Topic

Mail merge creates documents such as invoices, letters, contracts and reports from a template and data. In TX Text Control, the MailMerge class in the TXTextControl.DocumentServer namespace merges templates designed in MS Word or the Document Editor with JSON data, business objects or other data sources, and you save the result as PDF, DOCX or another supported format. The tutorials take you from your first merged document to invoices with repeating line items.

How Mail Merge Works

Every merge has the same three parts: a template, the data, and a MailMerge instance that brings them together. The template is a regular DOCX or TX document, designed in MS Word or the Document Editor, with merge fields as placeholders for single values and merge blocks for sections that repeat for each record of a collection, such as invoice line items. The data is JSON, a business object or a DataTable, prepared in the hierarchy the document needs. MailMerge in the Overview describes templates, data sources and the settings of a merge.

Pages in This Section

  • Simple Mail Merge: create a console application, merge JSON data and business objects into a template, and save the result as PDF and DOCX.
  • Merge Fields: how field names map to your data, how to insert fields in MS Word, the Document Editor or code, and how to format merged values.
  • Merge Blocks: repeat table rows and sections for arrays in your data, create blocks in code, nest them, and sort and filter their data.

If you are new to mail merge, start with Simple Mail Merge.

Next Steps