What is Mail Merge

Mail Merge is LibreOffice tool that allows us to produce multiple documents from a single document using a data source. To better understand what is mail merge let's examine the following scenario.

A business owner wants to send a newsletter to all the customers to promote a new product. The letter is a document containing the company information and some standard text. Instead of sending the same letter to all customers, the business owner wants to personalize the document by addressing each customer by his/her title, First and Last Name.

For a small number of customers the owner can simply copy and paste the text and change only the Title and Name for each customer. However this process becomes tedious and time consuming for a larger number of customer entries.

Mail merge solves this problem by allowing us to make multiple copies of a document and automatically inserting data from a source to certain parts of the document. Mail Merge was first used to produce mailing letters but has multiple applications as well. For example you can issue multiple certificates for a school using a certificate template and data containing the student names. If the data source contains email addresses, you can also use mail merge to send a document to multiple addressees by email.

Preparation

Before using the Mail Merge tool you must

  • Have your data source ready
  • Create the source document
  • Define the dynamic parts of the source document,  that will be merged from the data source.

The data source

In it's simples form the data source can be any spreadsheet containing data in table format. The first row of the spreadsheet must contain the field or column names. For our example the spreadsheet is shown below.

A data source can be also a table from a LibreOffice Database.

The source document

The source document can be any Writer Document. A good practice is to mark the dynamic parts of the document using generic titles or custom text fields. In our example the dynamic parts where the Title, First and Last name of the customer.

Using Mail Merge

The Mail Merge process involves three main steps

  1. Connecting the data source with the source document
  2. Inserting the table fields to the document
  3. Produce the output (or merge) the documents.

Connecting the data source.

Open the source document and choose Edit > Exchange Database menu item.

This command opens the Exchange Database window

The Available Databases pane will contain only the Bibliography database (a pre installed LibreOffice database).

  1. Click the Browse button and find the mail-merge-sample-data.ods file (or any file you use as a data source).
  2. Then select the Sheet1 and
  3. click Define.

Now the data source is connected with your document and you have access to the table fields.

Insert the data fields to your document.

With your source document still open select the View > Data Sources menu command (or press F4).

Now the top of the Writer Windows displays the Data Sources window. On the left you can browse the connected data sources and on the right the data are displayed. Make sure the correct data source is selected. On the right pane you can sort and filter the data if required.

Now select the Title field from the table and drag it to the [Title] placeholder inside the document. This automatically creates a field in the document that is connected with the title field in the data source. Delete the [Title] placeholder because is no longer required.

Repeat the above process and drag the the First Name and Last Name fields.

Producing the output

The quickest way to produce the output is using the Print button. Press the Print button and a dialog window will appear asking to print a form letter. Select Yes.

In the Mail Merge window you can set up the various options.

Output type

Printer. Will send the output to a printer

File. Will send the output to a file, thus it will save as odt or pdf file.

Save merged document

This setting applies only when the File option is selected.

Save as a single document. The merge output produces a single document. If for example the data source has 10 records and the master document is one page long the output document will contain 10 pages in total.

Save as individual documents. Creates a separate document for each record of the data source, for 10 records in data source for examole 10 documents will be created.

Generate file name form database. If you select this option you can name each output file using data from each record.

Field. You can use a field from the data source to name each output file.

Path. The path where the output will be saved.

File format. The file format of the output, it can be any format supported by LibreOffice

In our example if you choose Save as single document as single document will be produced containing all the newsletters.

If on the other hand choose Save as individual documents and disable the Generate filename option you must specify a base name and a path for the outputl

Choose a base name (for example newsletter) and save the output into a separate folder to avoid messing up your current folder. The files will be auto numbered as shown in the image below.

Last modified: Sunday, 14 January 2018, 10:02 PM