Learn more about sending email, using templates, and using expressions with workflow in the Workflow: Sending Email section.

Email Templates

You can control the content and format for your email body and attachment with a template, contained in either a Google Docs or Microsoft Word document.. Your template may include:

The email body or attachment will contain your template with all variables and expressions evaluated and replaced with the resulting values, as described below.

You can use template files for both event-triggered and scheduled reports. The templates for both are largely identical, differing only in the start expression used to select the table rows being displayed.

Template Data Sources

We support Google Docs template files stored on these data sources:

  • Google Drive

We support Microsoft Word template files stored on these data sources:

  • Box
  • Dropbox
  • Google Drive
  • Microsoft Office 365
  • Microsoft OneDrive

If you wish to use a workflow template, your account must include one or more of these data sources. Add a new data source from the Account > Data Sources tab.

Creating a Workflow Template

You can ask AppSheet to create a sample template file that displays the rows in your tables that you can then customize as you see fit. This makes template creation much easier.

Create a sample template file as follows:

  1. Add a new workflow or report and save it for the first time. Alternatively, open any existing workflow or report.
  2. Click the Create button following either the Attachment Template or Email Body Template property. When you click Create, AppSheet will create a sample template and write it to your default data source.
  3. The template will be given a unique name based on the workflow or report name, the template type (i.e., Attachment or Body), and the date and time you click Create, ensuring every template has a unique name.
  4. Click View to view and edit the new template file.

The Email Body Template always refers to a single Google Docs or Microsoft Word doc template file. You cannot use an expression to specify the Email Body Template file. If you need to choose between two or more template files, define a separate workflow rule for each template file and specify an expression in the Condition property to select which workflow rule to invoke.

Controlling the Workflow Template Data Source

By default, the template is created on your default data source. For example, if your default data source is Google, the Create button will create a Google Docs template file on Google Drive. If your default data source is Box, Dropbox, Microsoft Office 365, or Microsoft OneDrive, the Create button will create a Microsoft Word doc template file on your default data source.

The Editor fields Email Body Template Data Source and Attachment Template Data Source indicate which data source contains your template files.

You can control which data source is used by clicking the Browse icon and selecting a Google Docs or Microsoft Word doc template file using the Get data from ... dialog box. If you click the Create button after doing so, the created template will be saved on the data source you selected while browsing.

Viewing or Editing a Workflow Template

Once the template is created, click the View button to view or edit the template.

The View button works well for Google Docs.

The View button does not work well for Microsoft Word docs because of built-in limitations in the way Microsoft Word docs can be opened and edited from the web. Instead, login to your data source and edit the template file there.

Template Formatting Tips

The following tips may help you control the appearance of your PDF attachments.

In Google Docs:

  1. Under Format > Line spacing, reduce the line spacing to Single if it is currently larger, such as 1.5, Double, etc.
  2. Under Format > Line spacing, remove Add space before paragraph and Add space after paragraph.
  3. Under Format > Paragraph styles, change the header formatting to Normal Text rather than Heading 1, Heading 2, etc. Then apply formatting to control the header's font size, color, boldness, etc.
  4. Remove any excess blank lines.
  5. Under File > Page setup..., check the page size and margins. For example, consider setting the page size to A4 and reducing the top and bottom margins.

In Microsoft Word:

  1. Try the ideas described for Google Docs.

Viewing the Template in HTML Format

The Google Docs or Microsoft Word template is read in HTML format when it is retrieved by AppSheet. AppSheet then replaces the template variables in the HTML template with the data values you specify. The resulting HTML document becomes the email body or attachment. For email attachments, we convert the HTML document to PDF format and add the result as the attachment.

When you are designing your template, it can be helpful to see what your template looks like in HTML format. This allows you to fine tune your Google Docs or Microsoft Word template to yield better looking HTML.

In Google Docs:

  1. Open the template in Google Docs.
  2. In the Google Docs File menu, click Download as and select Web Page (.html zipped).
  3. If you are using the Chrome browser in Windows, the browser will download the file as a zip file and display a message at the bottom of your browser window.
  4. Click the up arrow and select Show in folder.
  5. Right-click on the zip file and select Extract All .... This will extract the HTML file from the zip file.
  6. Double-click on the extracted HTML file to view it in the browser.

Page Breaks in PDF Attachments

You can include page breaks in the PDF file created from an attachment template file by manually inserting a page break in the template.

In Google Docs:

  1. Position the cursor where you want the page break to occur.
  2. From the Google Docs Insert menu, select Page break.

In Microsoft Word:

  1. Select the Insert tab.
  2. Position the cursor where you want the page break to occur.
  3. From the Microsoft Word Pages menu, select Page Break.

Page Headers, Page Footers, and Page Numbering

Workflow templates do not support the Google Docs or Microsoft Word page header, footer, or page numbering features.

Using Custom Fonts

You can use custom fonts in your Google Docs attachment template file. The resulting PDF attachment file will use these custom fonts.

Do this as follows:

  1. Open your Google Docs template file in Google Docs.
  2. From the fonts dropdown on the Google Docs menu bar, select "More fonts ...".
  3. In the "Fonts" dialog box that is displayed, look at "My fonts" on the right side of the dialog box.
  4. If the font you wish to use is not displayed, use the "Search" box to find the font. For example, you can use the "Libre Barcode" fonts. To choose one or more of these fonts, enter "Libre Barcode" in the "Search" box. This should display a list of five "Libre Barcode" fonts. Fonts you are using should be displayed in blue text with a checkmark to their left. If a font is missing, click it and the font should be displayed in blue text with a checkmark to its left.
  5. In your workflow template, select the text you wish to assign a custom font, and select the font name from the "Fonts" dropdown on the Google Docs menu bar.
  6. Trigger your workflow rule and ensure the PDF attachment is using the custom font.

If you encounter problems with custom fonts, see Troubleshooting Custom Fonts .

Did this answer your question?