Managing email templates

Kentico sends automatic system emails for various purposes, for example, workflow notifications. The content of such emails is determined by templates according to the type of the given email. Many Kentico features send emails based on predefined templates that are included in the default installation.

Managing email templates

To edit the email templates, open the Email templates application. Editing email templates enables you to alter the emails sent by the system to match the required design and/or language.

There are two types of email templates:

  • Global - only users with the Global administrator privilege level can manage global email templates. Choose the (global) option in the Site selector.
  • Site-specific - allow you to override the global templates for specific websites. You need to select the appropriate Site and create a new template with a Code name that matches the corresponding global template.

The system only contains global templates by default.

When editing email templates, the following properties are available:

Property

Description

Display name

The name of the template displayed in the administration interface.

Code name

Serves as a unique identifier of the email template (for example in the API).

Description

Allows users to add custom notes about the email template (describe where and how the template is used etc.).

Email type

Identifies the type of functionality to which the template is related. This can be used to categorize and filter email templates.

From

Email address used as the sender (‘From’) address of the email.

Reply to

Email address used as the recipient (‘To’) when replying to the email.

Cc

Email addresses of copy recipients.

Bcc

Email addresses of blind copy recipients (receive a copy of the email, but cannot see the addresses of other recipients in the mail).

Subject

The subject of the email.

HTML version

Defines the content that is used for the template when sending emails in HTML format. Supports all standard HTML tags and syntax (tables etc.).

You can select the preferred format using the Settings -> System -> Emails -> Email format setting.

Plain text version

Plain text version of the email template.

Example of the HTML version of a template:




<html>
  <head>
  </head>
  <body style="font-size: 12px; font-family: arial">
    <p>
      This is an automatic notification sent by Kentico. The following page is waiting for your approval. Please sign in to the Kentico administration interface and approve it.
    </p>
    <p>
      <strong>Page:</strong> <a href="{%DocumentEditUrl%}">{%documentname%}</a> {% ifEmpty(DocumentPreviewUrl, "", "(<a href=\"" + DocumentPreviewUrl + "\">preview</a>)")|(encode)false%}
      <br />
      <strong>Last approved by:</strong> {%approvedby%}
      <br />
      <strong>Last approved when:</strong> {%approvedwhen%}
      <br />
      <strong>Original step:</strong> {%originalstepname%}
      <br />
      <strong>Current step:</strong> {%currentstepname%}
      <br />
      <strong>Comment:</strong>
      <br />
      {%comment%}
    </p>
  </body>
</html>


Most templates contain macro expressions (such as {% currentstepname %}), which the system resolves dynamically when sending the emails. The use of macros is necessary to ensure that individual emails contain information relevant to the situation that caused the email to be sent. You can add macros into fields by clicking Insert macro () or write the required expressions manually.

If you wish to display data loaded via a macro in a specific format, you can apply transformations. See Using transformations in macro expressions for more information.

You can attach files to an email template through the Attachments button in the header of the template editing page. The attachments are included when the system sends out emails based on the given template. Clicking the button opens a dialog where you can manage the attachments.

Previewing email templates

If you want to view the appearance of an email based on an email template, you can send a preview of the template to specified email addresses via the Send draft button.

The preview email behaves as a real email sent to a user by the system, except when resolving macro expressions. Email template context specific macro expressions do not resolve in the preview emails. For example, in the E-commerce - Order notification to customer email template all macro expressions requiring the context of an order (e.g. {% Order.OrderInvoiceNumber %}) do not resolve, because no order data is available for the draft.

The preview email also includes all attachments specified for the email template.