# Mail Merge

> Mail merge with the MailMerge class: templates from MS Word or the Document Editor, merge fields, merge blocks and JSON, object or DataTable data sources.

- **Product:** TX Text Control .NET Server
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET Server > Getting Started > Mail Merge
- **479 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/getting-started/mail-merge/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/getting-started/mail-merge/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/getting-started/mail-merge/llms-full.txt

---

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](https://docs.textcontrol.com/tx-text-control-dotnet-server/overview/components/mailmerge/llms-full.txt) in the Overview describes templates, data sources and the settings of a merge.

### Pages in This Section

- [Simple Mail Merge](https://docs.textcontrol.com/tx-text-control-dotnet-server/getting-started/mail-merge/simple/llms-full.txt): create a console application, merge JSON data and business objects into a template, and save the result as PDF and DOCX.
- [Merge Fields](https://docs.textcontrol.com/tx-text-control-dotnet-server/getting-started/mail-merge/fields/llms-full.txt): 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](https://docs.textcontrol.com/tx-text-control-dotnet-server/getting-started/mail-merge/blocks/llms-full.txt): 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](https://docs.textcontrol.com/tx-text-control-dotnet-server/getting-started/mail-merge/simple/llms-full.txt).

### Next Steps

- [Mail Merge and Reporting](https://docs.textcontrol.com/tx-text-control-dotnet-server/mail-merge/llms-full.txt) covers data sources, conditional content, images, barcodes and template design in depth.
- [Document Editor with ASP.NET Core](https://docs.textcontrol.com/tx-text-control-dotnet-server/getting-started/document-editor/aspnet-core/llms-full.txt) shows how to add the editor your users design templates with.
- The [Mail Merge Template Assistant](https://demos.textcontrol.com/demos/rich-text-editor/mail-merge-template-designer) online demo walks you through fields, nested blocks, sorting and filtering with a live template.

---

## In This Section

- [Merge Blocks](https://docs.textcontrol.com/tx-text-control-dotnet-server/getting-started/mail-merge/blocks/llms-full.txt): Repeat table rows and sections such as invoice line items with merge blocks: map block names to arrays, create blocks in code, nest, sort and filter them.
- [Merge Fields](https://docs.textcontrol.com/tx-text-control-dotnet-server/getting-started/mail-merge/fields/llms-full.txt): Map merge field names to JSON and object data with dot notation, insert fields in MS Word, the Document Editor or C#, and format merged numbers and dates.
- [Simple Mail Merge](https://docs.textcontrol.com/tx-text-control-dotnet-server/getting-started/mail-merge/simple/llms-full.txt): Create your first mail merge in a .NET console app: merge JSON data and C# objects into a DOCX template, save PDF and DOCX, and run it on Linux or WSL.

---

## Nearby

- **Previous:** [JavaScript](https://docs.textcontrol.com/tx-text-control-dotnet-server/getting-started/document-viewer/javascript/llms-full.txt)
- **Next:** [Simple Mail Merge](https://docs.textcontrol.com/tx-text-control-dotnet-server/getting-started/mail-merge/simple/llms-full.txt)
