Create a different template for each table that uses the email client to pre-populate data for recipients and email content.

Before you begin

Role required: admin

About this task

The email client uses its own email templates to define default values for fields. Use the following sections in the Email Client Template form to build a client template:
  • Content: The message body.
  • Recipients: The email addresses of users receiving the email message. The email addresses are displayed in the To, Cc, and Bcc fields of the message.
  • Sender Configuration: The method used to generate the email sender (From email address) of the message.

Procedure

  1. Navigate to All > Email Client > Email Client Templates.
  2. Select New.
  3. On the form, fill in the fields.
  4. On the Content tab, fill in the fields.
  5. On the Recipients tab, fill in the fields.
    Table 3. Recipients tab
    Field Action
    To Enter a comma-separated list of either field names that contain user email addresses or just email addresses. To reference an email address using a script, create a script include and then call the script include in the To field. Your script must start with the javascript: prefix. The script must return email addresses in a comma-separated string.
    Cc

    Enter a comma-separated list of either field names that contain user email addresses or just email addresses. To reference an email address using a script, create a script include and then call the script include in the Cc field. Your script must start with the javascript: prefix. The script must return email addresses in a comma-separated string.

    This field can’t have the same addresses as the To field.

    Bcc

    Enter a comma-separated list of either field names that contain user email addresses or specific email addresses. To reference an email address using a script, create a script include and then call the script include in the Bcc field. Your script must start with the javascript: prefix. The script must return email addresses in a comma-separated string.

    This field can’t have the same addresses as the To or Cc fields.

  6. On the Sender Configuration tab, select the From Generation Type method to determine how the sender (From address) in the email client message is generated.
    Use this method only if you want a different From address than the one defined in your SMTP email account.
    • None: The From address isn’t generated in the email client message.
    • SMTP Email Account: Use the From address of the SMTP email account for the instance as the sender.
    • Select From List: Choose from a list of allowable From addresses defined in the Email Client From Address [sys_email_client_from_address] table.
    • Script: Run a GlideRecord query on the Email Client From Address [sys_email_client_from_address] table.
      For example, the following script sets the From address based on the location of the incident caller:
      (function (fromAddressQuery, targetRecord) {
          // targetRecord is incident for this template
          var location = targetRecord.caller_id.country;
      
          if (location == 'us')
              fromAddressQuery.addQuery('email_address', 'servicedesk.us@example.com');
          else if (location == 'japan')
              fromAddressQuery.addQuery('email_address', 'servicedesk.jp@example.com');
          else if (location == 'uk')
              fromAddressQuery.addQuery('email_address', 'servicedesk.uk@example.com');
      
      })(fromAddressQuery, targetRecord);
    • Text: Enter the email From address to be used in the client.
    Note:

    The From email address doesn’t appear in the email client unless you configure an email client to display the From address. For more information on managing the behavior of an email client, see Email client configurations.

    If the domain for the From address isn’t the domain of the SMTP email account server, the owner of the From domain address must configure the SPF record for the domain. The owner changes the domain settings to enable the instance to send an email as if from that domain. For more information on using SPF records, see ServiceNow KB0535456.

  7. Select Submit.
    The template is added to the Email Client Templates [sys_email_client_template] table.

Apply an email client template

After you create an email client template, you can apply it to an email.

Before you begin

Role required: admin

About this task

The following steps are implemented only after creating an email client template

Procedure

  1. Click the ellipsis (...) icon at the top of the template to apply the template to an email.
  2. Select Email.
  3. Fill in the fields to compose an email.
    See Create an email client template for field details.
    Note: The body of the email is filled up with the details from the incident record. If you modify one or more fields in the incident record and are not saved, the unsaved changes still reflect in the email body.
    Note: 2000 characters is the total limit for all the changes in the incident record. If some of your changes are not reflected and get truncated in the email body, this is because the total changes is more than 2000 character limit.

Create an email client response template

You can now create custom email client response templates that support conditions.

Before you begin

Role required: admin

About this task

Email client template is applied automatically in the email client based on the specified table, conditions, and execution order.

Procedure

  1. Navigate to All > Email Client > Email Client Templates.
    The following options for Response Template - Received and Response Template - Sent show up.
  2. Click one of the available options to create a template for that selected option.
  3. Fill in the fields at the top of the Email Client Template form.
  4. Fill in the fields in the Content tab.
  5. Fill in the fields in the Recipients tab.
    Field Description
    To Enter a comma-separated list of either field names that contain user email addresses or specific email addresses. To reference an email address using a script, create a script include and then call the script include in the To field. Your script must start with the javascript: prefix. The script must return email addresses in a comma-separated string.
    Cc

    Enter a comma-separated list of either field names that contain user email addresses or specific email addresses. To reference an email address using a script, create a script include and then call the script include in the Cc field. Your script must start with the javascript: prefix. The script must return email addresses in a comma-separated string.

    This field cannot have the same addresses as the To field.

    Bcc

    Enter a comma-separated list of either field names that contain user email addresses or specific email addresses. To reference an email address using a script, create a script include and then call the script include in the Bcc field. Your script must start with the javascript: prefix. The script must return email addresses in a comma-separated string.

    This field cannot have the same addresses as the To or Cc fields.

  6. In the Sender Configuration tab, select the From Generation Type to determine how the sender (From address) in the email client message is generated.
    Use this field only if you want a different From address than the one defined in your SMTP email account.
    • None: The From address is not generated in the email client message.
    • SMTP Email Account: Use the From address of the SMTP email account for the instance as the sender.
    • Select From List: Choose from a list of allowable From addresses defined in the Email Client From Address [sys_email_client_from_address] table.
    • Script: Run a GlideRecord query on the Email Client From Address [sys_email_client_from_address] table.
      For example, the following script sets the From address based on the location of the incident caller:
      (function (fromAddressQuery, targetRecord) {
          // targetRecord is incident for this template
          var location = targetRecord.caller_id.country;
      
          if (location == 'us')
              fromAddressQuery.addQuery('email_address', 'servicedesk.us@example.com');
          else if (location == 'japan')
              fromAddressQuery.addQuery('email_address', 'servicedesk.jp@example.com');
          else if (location == 'uk')
              fromAddressQuery.addQuery('email_address', 'servicedesk.uk@example.com');
      
      })(fromAddressQuery, targetRecord);
    • Text: Enter the email From address to be used in the client.
    Note: The From email address does not appear in the email client unless you configure email client to display the From address. For more information on managing the behavior of email client, see Email client configurations.

    If the domain for the From address is not the domain of the SMTP email account server, the owner of the From domain must configure the SPF record for the domain. The owner changes the domain settings to allow the instance to send email as if from that domain. For details on using SPF records, see ServiceNow KB0535456.

  7. Click Submit.