Previous

Include tables in the email text

  • 10 min.

You can cleverly organize merge fields inside your template email body text, using the merge tables feature in Document Output. With this feature, the body text of your email template can include tables of merged data that summarize the information from the attached PDF document. You could even merge all the necessary document information into the email body text so that you can skip the attachment altogether. For example, a document such as a shipment notice might not require an attached file if all the necessary information is in the email text.

In the image of an example shipment notice email, two merge tables are included. The first table, labeled A, shows merged fields from the sales shipment header table, such as order number, customer address and shipment date. The second table, labeled B, shows merged fields from the sales shipment lines table, and adds a bottom row that sums the quantity.

DO Learn Mod 1-9-Shipment email Merge Table multiple tables

The merge table feature in Document Output improves on a standard email text table in these ways:

  • Displaying as many columns or rows that are found in the source data for the Business Central document. For example, different sales shipment documents have a different amount of item lines.
  • Including cells that sum columns or rows of data.
  • Flexible design options for the color of text, borders and cell backgrounds, and custom text padding so you can support your company's communication style and branding.

Adjust the merge data source, orientation and display order

Document Output comes with existing template tables for a range of email templates. These template tables will have a number of merge fields set up already, but can be adjusted further to include exactly what you need, and in the display order that suits you best.

From the relevant email template card, select Template in the action bar, and then Merge Tables to open the Merge Table Card. In each merge table card, you can:

  • Select which Business Central data is the source of the merge fields, under the General FastTab in the Table section. For example, merge fields for a shipment notice would come from the sales shipment header, or the sales shipment lines.
  • Choose whether the Table Type should be fields in rows, such as the table labeled A in the example email image, or fields in columns, such as table labeled B.
  • Select the Merge Table Fields to include, and determine their display order using the Number column.
  • View a Sample of the table, to preview the layout, order and labels used.
DO Learn Mod 1-10-Merge Table Card Table Number Field

Adjust labels and add header and footer cells

You can adjust the labels for the merged data, which can be useful when the Business Central caption for the field is lengthy, or not easy for your customers or vendors to understand. You can also add headings, display merge fields from other sources, or include cells that sum the merged data.

The example email in the image includes:

  • A left column for the table labeled A, such as the text Shipment, Ship-to Name and Tracking.
  • A top row for the table labeled B, with the text No., Description and Quantity.
  • A bottom row for the table labeled B, with the text Total quantity.
DO Learn Mod 1-9-Shipment email Merge Table multiple tables

You set up the label rows and columns in each merge table using the option for Table Layout in the action bar of the merge table card. The Cell Type column in the table layout card includes many of the most important options, including:

  • Caption, which displays the field name used in Business Central.
  • Text, to create your own label for a field in the Cell Text column.
  • Sum, to show the total of the data from the related cells in the same column or row, depending on whether the Table Type is either fields in rows or columns.
  • Merge Field, to use one of the merge fields set up in the email template rather than the Business Central table selected as the data source.
DO Learn Mod 1-11-Merge Table Top Left Bottom Cell type text

When working with top and bottom rows you might need to create a cell that functions to add space, by using Text as the Cell Type, and leaving the Cell Text empty. The example bottom row in the image shows an empty cell at [Row 2, Column 1]. Also, the sample in the image shows the effect of Text alignment for the cells at [Row 2, Column 2] and [Row 2, Column 3].

DO Learn Mod 1 Merge Table_Table Layout examples

Adjust table colors, borders and cell padding

You can change many style elements of merge tables, such as border width, text color, and cell padding. It's easiest to start with a pre-existing style template with the option Select Table Style, and then edit the style template to meet your company’s branding. This will create a template that you can easily apply it to other tables. To make style changes that apply to only the table you’re working on, but not the style template, use the Table Style action.

DO Learn Mod 1-13-Merge Table Card Select Table Style

Colors and borders can be set with the Table Border width and Table border color, and also for each type of line in the Style Lines. You can also change the cell Padding in the style lines.

DO Learn Mod 1-14-Table Style Card Style Lines

Include merge tables in an email HTML template

To include a table in an email template, you add a merge field for the table into the HTML email template. The example email on the right side of the image was created from the email template on the left side of the image below. You can see that the template includes the two merge fields for tables A and B.

DO Learn Mod 1-15-Merge fields in HTML template Tables

Leave out the PDF document attachment

If you have included all the necessary document information in the tables within the email body text, for some email templates you might consider leaving out PDF document attachments to save file storage space. The setting for Use reports for email attachments is usually enabled, but it can be turned off. This setting is in the main Email Template Card, under the Attachments FastTab.

DO Learn Mod 1-16-E-Mail Template Card Use reports for attachments

Scenario

In this scenario video, Robin, the warehouse manager at Cronus, adds and adjusts two merge tables in the email template for shipment notices.

Robin needs to work on these tasks:

  • Adjust the merge fields in tables
  • Adjust the row and column headings to more user-friendly names
  • Add in a sum cell for the total quantity
  • Adjust the table styles to match Cronus brand.
  • Add the two tables to the email template
  • Remove the document attachment from the email template