[![Mail merge][1] documents from a single template and a structured data source. For example, it can be used to create a letter that can be sent out to many recipients with only small changes, such as unique addresses or a change in the greeting line. Mail merge is also used to generate business reports, purchase orders, receipts, catalogs, inventories, and invoices etc.

Aspose.Words Cloud Mail Merge allows you to generate these documents from a template and XML in any language including .NET, Java, PHP, Ruby, Rails, Python, jQuery and many more. You can use it with any language or platform that supports REST. (Almost all platforms and languages support REST and provide native REST clients to work with REST APIs).

This post covers mailmerge in RUBY, read the Aspose.Words Cloud documentation for other languages. To execute a mailmerge, you need to upload a template to Aspose Cloud or any supported third party storage and then send a POST request (passing XML data in the request body) to generate documents based on template and data. The following steps describe the process in detail.

Decide which Type of Mail Merge to Execute

Aspose.Words Cloud supports simple mail merge and mailmerge with regions (to fill table fields and add rows dynamically). If you want to insert simple or non-repeating data, for example Name, Address and Code fields on an envelope or To and From fields in a letter, use simple mailmerge (also called mailmerge without regions).

If you are preparing reports, invoices and purchase orders, or other documents, and want to insert tables, rows or repeating data, or if you want your documents to dynamically grow based on your input data, use mailmerge with regions.

Prepare a Template

In order to prepare your template to perform a simple mail merge (without regions, similar to the classic mail merge available in Microsoft Word) insert one or more merge fields in the places you want to be populated with data from the data source. See Simple MailMerge Explained and Prepare a Document for more details.

If you want to dynamically grow portions inside the document, use mail merge with regions. To specify a mail merge region in the document you need to insert two mail merge fields to mark the beginning and