Working with email templates

For a variety of reasons, such as name changes or organizational changes, you'll be editing your email templates from time to time. In this article, you'll be introduced to how to do that.

To edit email templates

On the Email Template Card page, the General FastTab contains the information you'll see in the headers of your emails, such as From Email and Email Recipient, as well as data used in Business Central, such as Code, Report-ID and Dimension Code.

To edit an email template:

  1. Search () for and select Email Templates.
  2. In the list of templates, in the Code column, select the template you want to edit. The Email Template Card opens.
  3. On the General FastTab, you can edit a number of fields, including the following:
    • Report-ID – specifies the report number for this template. The report is used to create the PDF that's attached to the email.
    • Merge Fields – specifies the number of merge fields available for use.
    • Recipients Setup Lines – specifies the number of fields where Document Output looks for email recipients. For more information, see To configure email recipients below.
  4. In the From Email section, you can specify how to find the sender email address. The From Email field is the main field, with the remaining fields depending on what you select here. For more information, see To specify the sender below.

You've now edited the email template.

Hinweis

Variants are no longer set up on the template header. Instead, each line on the Email Template Line FastTab now carries its own variant criteria. For more information, see Using multiple variant criteria on template lines.

Email template FactBoxes

All email templates have three FactBoxes attached to them. They provide an easy overview of certain important information regarding recipients and the selected email template line. You find the FactBoxes in the right side of the screen when you open an email template. The FactBoxes are:

Recipients Setup – This FactBox displays the prioritized list of where the recipient email address is retrieved. You can use the dropdown menu to enter the Template Recipient Setup and change the list, including prioritization.

Template Line Attachment – This FactBox displays all attachments for the selected template line.

Document Output Log – This FactBox displays the log entries where the selected template line has been applied.

Tipp

If the FactBoxes are not displayed when you open an email template, select the Expand the FactBox Pane icon (a lowercase "i" in a circle) in the top right corner.

To configure email recipients

To make sure that every email has at least one recipient, the system currently uses the recipient email address from the customer card if no specific recipient is specified. However, the email templates provide various options to customize the email recipient setup based on document group, template type, or a fixed email address, offering a flexible approach to defining recipients for different scenarios.

To edit the recipient setup:

  1. Select the()icon, enter Email Templates, and then select the related link.
  2. From the list, select a template to edit, and on the action bar, select Edit.
  3. In the Recipient FastTab, you can edit the following fields:
    • Document group – email templates can be attached to a document group. This allows you to assign different email addresses for specific purposes, such as directing accounting-related emails to the finance department, sending contract-related emails to a particular contact, or sharing shipment details with a designated recipient within a different document group. Once a document group is defined on an email template, it will be used if it's defined in the customer email recipients in the customer FactBox.
    • Recipients Setup Lines – shows the number of configured recipient lines. These lines are used when you want to define from where the recipient email address for the specific email template type is retrieved. This means that you can establish a list of places from where the recipient email address is retrieved and set the priority for each according to your needs.
    • Email is mandatory – when enabled, checks if everything is ok for a configured email before a draft email is opened. When a draft email is opened, it will count as a sent document, regardless of whether it's been sent to the email server or not.
    • Fixed Cc Recipient(s) and Fixed Bcc Recipient(s) – used to send a copy of all emails of a specific document type to a sales representative or similar internal employee in your company when emails are sent out.
    • Test Recipient – overrides all configured email recipients configured in an email template.

To specify the sender

For each email template, you can specify how to find the sender email address (also known as the from email address) – that is, the address that appears as the sender on outgoing emails.

To specify the sender email address, follow these steps:

  1. Search () for and select Email Templates.
  2. In the list of templates, in the Code column, select the template whose sender email address you want to specify. The Email Template Card opens.
  3. On the General FastTab, go to the From Email section.
  4. In From Email, choose one of the following options:
    • Fixed: Always uses the exact From Email Address and From Email Name entered on the template. This never changes based on who or what sends the email. Continue to step 5 below.

    • User Setup: Uses the email address found on the User Setup record of the Business Central user who's sending the email. Continue to step 6 below.

    • Salesperson from User Setup: Finds the salesperson that's linked to the sending user's User Setup record and uses that salesperson's name and email address as the sender. Continue to step 6 below.

    • Use From Email Address Field: Reads the sender address directly from a field on the document being sent, as specified separately in From Email Address Field. Continue to step 7 below.

      Note

      If the lookup for User Setup, Salesperson from User Setup, or Use From Email Address Field comes back empty – if, for example, the user has no email set in User Setup, no salesperson is linked, or the document field is blank – Document Output doesn't show an error. It silently uses the Fixed address from the template instead as a fallback.

  5. If you selected Fixed in step 4 above, fill out From Email Address with the email address that you want to appear as the sender, and then skip to step 8 below.
  6. If you selected User Setup or Salesperson from User Setup in step 4 above, select one of the following options in Find from address on queue, and then skip to step 8 below:
    • Use dispatcher's User ID (default): The sender is looked up based on whichever account is actually running the batch job at the time of sending.

    • Use Queued by User ID: The sender is looked up based on whichever person originally queued the document for sending, even though a batch job sends it later.

      Note

      This setting only applies when a document is emailed through a scheduled or batch send rather than someone clicking Send directly.

  7. If you selected Use From Email Address Field in step 4 above, fill out From Email Address Field with the document field that you want the sender address to be read from. Select the three dots to open the Fields (With Relation) page, and then choose the field from there.
  8. To have the from email address displayed when the email is opened in Business Central, enable Show From Email Address.

You've now specified the sender email address, and the headers of your outgoing emails will be updated accordingly. However, note that the sender configuration is affected by which sending channel you've set up.

How sending channels affect the From Email options

Document Output can send email through one of three different channels, depending on your setup:

  • Business Central email accounts (Email Accounts)
  • Azure (Document Output Azure Application)
  • On-premises (Document Output SMTP)

Which channel to use is configured separately from the From Email options (described under To specify the sender above) – in the Document Output Setup > General FastTab > Email Sending Method. The selected channel determines whether the configured sender email address is actually used:

  • Email Accounts: Document Output checks whether the specified sender address matches an email account already registered in Business Central. If there's no match, the address is disregarded, and the email is sent from whichever account is set as the default instead.

    Note

    This means that User Setup, Salesperson from User Setup, and Use From Email Address Field only work reliably for this channel if a matching mailbox is registered in Business Central for every possible sender.

  • Document Output Azure Application: Emails are sent through a Continia-owned connection to Microsoft 365, which is set up once with tenant-wide permission to send as anyone in the organization (see Creating an App Registration in Azure Active Directory). No per-mailbox registration is required, so whatever address the From Email option resolves to is used as-is. This is the only channel where all four From Email options behave exactly as configured.

  • Document Output SMTP: This channel is only available in on-premises environments. The resolved sender address is passed directly to the customer's own mail server. Whether the recipient sees it correctly depends entirely on that server's own configuration, which is outside of Document Output's control.

Hinweis

From Email determines what address Document Output sends from, whereas the sending channel decides whether that address actually reaches the recipient. The same From Email setting can work perfectly on one channel and silently fail over to the Fixed address on another.

To add or edit email template lines

The Email Template Lines FastTab allows you to edit the information in the email itself, such as the email text, the signature, and the subject field.

To add or edit an email template line:

  1. Search () for and select Email Templates.

  2. In the list of templates, in the Code column, select the template whose lines you want to edit. The Email Template Card opens.

  3. On the Email Template Line FastTab, to add, edit, or copy a line, select Manage on the FastTab title bar, and then click one of the following:

    • New Line: Adds a new template line.
    • Delete Line: Deletes the currently selected line.
    • Copy Line: Copies the currently selected line. See To copy email template lines below.
  4. To edit the email text, click Email Template > Edit HTML Template.

    Tip

    It's super easy to insert merge fields into your HTML template. Just enter a %, which will make a list of all available merge fields appear. Pick one and you're done!

  5. To add variant criteria to a line or edit existing ones, click Variant Criteria. For more information, see Using multiple variant criteria on template lines.

  6. To pick a PDF that will be used as background for your template, click Background PDF > Set Background PDF.

    Important

    Engine must be set to NAV-PDF on either the template or the Document Output Setup page. You can read more about this in the Setting a Background PDF.

  7. To add pages from a PDF to the resulting PDF report, click Merge PDF > Set Merge PDF File.

  8. You can also edit each individual line directly in the list of template lines. Go to one or more of the following columns and make any necessary changes:

Tipp

If an invoice doesn't use the correct template, it's possible that you forgot to save the HTML template after having edited it. Unlike other options in Business Central, HTML templates are not saved automatically. To avoid this issue, ensure that you select Save when you've edited an HTML template.

Wichtig

Always leave Language Code empty, and leave all variant criteria removed, on one line per template (typically the first). This is the catch-all line, used if a document doesn't match the language or the variant criteria of any other line.

To attach open documents to template lines

You can attach open customer documents to any or all of the lines in a template. This applies to reminders, finance charges, and statements.

To attach open documents to one or more template lines, follow these steps:

  1. Search()for and select Email Templates.
  2. In the list of templates, select the one whose lines you want to edit, and then click on the template code in the Code column to open the Email Template Card.
  3. On the Email Template Line FastTab, select the line that you want to edit.
  4. In Attach/merge open documents, select the option you prefer:
    • Attach as individual files: Attaches any relevant open documents as individual, separate files.
    • Attach as One File (ZIP or PDF): Attaches any relevant open documents as one single file in either ZIP or PDF format, as specified in step 5 below.
    • Merge with original document: Merges any relevant open documents with the original document to form one single file comprising all documents.
  5. If you selected Attach as One File in step 4 above: In Attach Open Doc. File Name, specify if you want the attached file to be a ZIP or a PDF file. You do this by entering a file name followed by the file extension of your preferred format (.zip or .pdf).
  6. Repeat steps 3-5 for any additional lines you want to attach open documents to.

The relevant open documents will now be attached to the selected lines according to your setup.

Hinweis

Open documents will only be included if a valid email template exists for the specific open document types.

To copy email template lines

It's easy to copy email template lines for language variants, etc. in Document Output. Go to any email template, and do the following:

  1. In the Email Template Lines FastTab, select the email template line you want to copy.
  2. On the action bar, click Manage > Copy Line > Yes.
  3. In the Copy Email Template Line dialog, optionally enter a Language Code for the copy (leave it blank to keep the language of the line being copied).
  4. Under Variant Criteria, edit the copied criteria, or use Add Criterion and Delete Criterion to change what the copy matches on, so that it doesn't collide with the line that it was copied from.
  5. Enable the line by selecting the checkbox in the Enabled column.

To create a new email template

Continia Document Output comes with several ready-to-use email templates so you can start sending documents immediately.

Naturally, you also have the option to create your email templates from scratch. However, it's highly recommended to always use one of the existing templates as a starting point and then carry out the necessary corrections. This is because, usually, a lot of the information in a template, such as merge fields, recipient(s), etc., can be reused.

To create a new email template:

  1. Search () for and select Email Templates.
  2. On the action bar, click New.
  3. In the General FastTab, fill out the fields as necessary.
  4. In the Email Template Lines FastTab, fill out the fields and use the actions as necessary.
  5. On the General FastTab, the Merge fields field helps to insert dynamic customer-specific data, such as invoice numbers, customer names or addresses, or company logos, into email lines, signatures, or file names. When you use merge fields, you ensure that changes to your customer data are reflected in all relevant places as soon as modifications occur on customer cards.
  6. On all email templates, you'll find an attached report selection that can be used for the general layout of the email content. From this report selection, the First Table field in Report will indicate where the available merge fields are fetched. You can view a list of available merge fields in the template you're modifying by selecting the number next to the merge field caption. This will open a list of the merge fields that are available for use.

To use custom reports and layouts in email templates

Reports allow you to structure, display, print, or in various other ways process information from your database – for example, to present data in a readable format in Business Central (as sales invoices, for instance). The content and format of each report is determined by the built-in report layout.

Built-in layouts can't be modified, but you can create custom layouts and assign one or more of these to a report, thereby customizing the report. You can also create custom reports as new or modified report objects using AL code (changing the dataset, logic, or structure). Such custom layouts and reports can then be used in Document Output templates.

To use a custom report in an email template, follow these steps:

  1. Do one of the following, depending on what you want to do:
  2. On the Email template card, go to the General FastTab. In the Report section, choose one of the following two ways to link your custom report to the email template:
    • To link the report to the template via the report selection feature, click the Report Selection Usage field to open the corresponding page, and then select the report selection option you prefer.

      Note

      For your custom report to be linked using this method, the report selection option you select must have been set up to link to this particular report.

    • To link directly to your specific report, click Report ID to open a dropdown menu, and then click Select from full list to open the Select - Objects - Report page. From there, select your report in the list, and then click OK to close the page.

      Tip

      When you select Report ID, you can add a layout for each email template line, which will then override the default layout: On the Email Template Lines FastTab, select the relevant template line, and then select a layout in the Report Layout column. This is optional though, so if no template line layout is added, the deafult layout will be used instead.

  3. In the Template table section, click the First Table in Report field to open a dropdown menu, and then click Select from full list to open the Select - Table Objects page. From there, select the table that should be the first table in the report.
  4. Fill out or edit No. of Merge Fields and the relevant Recipients and From Email fields as needed.
  5. On the Linked To FastTab, click the Linked to field to open a dropdown menu, and then select the table that you want the template to be linked to.
  6. In the Advanced section, click the Engine field to open a dropdown menu, and then select a file engine that matches the layout of your report.

Your custom report is now linked to and set up for the email template that you selected or created in step 1.

Support of email templates in multiple languages

Being able to send your documents in the specific languages of your customers can be a great way of distinguishing your company from competitors, and it may even be required by some of the customers. Overall, you have two options for creating multiple language versions of your documents:

  • Letting Translate with Copilot translate the text of your existing email templates
  • Importing predefined email templates in a specific language

The Translate with Copilot action lets you start with a copy of the text in your existing email HTML template. This is useful if you've already edited the default email template to suit your company.

To use the Translate with Copilot action, follow these steps:

  1. On the Email template card, in the Email Template Lines FastTab, select a line to copy in the table.
  2. In the FastTab action bar, select Manage > Copy Line.
  3. In the dialog that opens, select Yes to confirm that you want to copy the line.
  4. In Language Code, specify the language code for the new email template line. Select OK to close the dialog and return to the email template card.
  5. Select the new email template line.
  6. In the FastTab action bar, select Email Template > Edit HTML Template.
  7. Select Translate with Copilot, and then select the appropriate language.
  8. Under Subject, manually translate the subject line, if necessary.
  9. On the action bar, click Save Email Template when you're done.

The translated email template is now saved and ready for use.

Alternatively, you can use the predefined language email templates provided by Continia. When you run the assisted setup guide during the installation of Document Output, it will automatically import email templates that match the language of your Business Central database, but Document Output also includes functionality to import predefined language variants of these email templates.

To import predefined email templates in a specific language, follow these steps:

  1. Select the()icon, enter Email Templates, and then select the related link.
  2. On the action bar, click Template > Download Template.
  3. In the list, select the language you want to import email templates for, and select OK.
  4. In the Action column, you can choose between three actions for each template: Create to create the language variant template, Replace to create the language variant template and make it the default template, and Skip to skip the creation of this email template variant. As default, all email template language variants are marked as Create.
  5. After you've made your selections, select OK to complete the import.

You find your email template language variants under each default email template as email template lines.

Merging PDF Files
Signing PDF Files
Password Protecting PDF Files