Sign in
    Shared Email Templates

    Insert-if sections: Add, change, and remove conditions

    In Shared Email Templates for Outlook, you can add a condition to a paragraph, list, list item, table, or table row. You can also add a condition to multiple sections at once or to selected text within a paragraph, list item, or table cell. A template part that has a condition applied to it becomes an Insert-if section.

    An Insert-if section is inserted into an email message along with the rest of the template only if the condition is met.

    Read less!
    Grab cheat sheet instead

    How to add a condition #

    You can base a condition on text in an email message field or on the result returned by the WhatToEnter macro.

    Adding a condition based on text in a message field #

    1. Start creating or editing your template.

    2. Right-click the template part you want to add a condition to (a paragraph, list, list item, table, or table row), and then select an option to add a condition.

      Adding a condition to a paragraph
    3. Define the condition:

      • Under Find in, keep Message fields selected.
      • Choose the fields to check for the condition (body, from, to, cc, bcc, subject, location, recipient first, last, or full name, sender first, last, or full name).
      • Select the condition (contains, doesn’t contain, contains any of, contains none of, is equal to, is equal to any of, is equal to none of, is empty, is not empty, matches regex, or doesn’t match regex).
      • Enter the text or regex to look for.

      When you’re ready, select OK.

    4. The template part to which the condition is applied will be marked with a green indicator. Save your template.

      A green indicator in a sample template

    When you insert the template into an email message, the add-in checks the specified message fields. The Insert-if section is inserted only if the condition is met.

    The template part is inserted because the condition is met.

    How to add complex conditions #

    You can combine multiple conditions with the AND and OR logical operators by selecting the corresponding buttons. This allows you to add complex conditions to template parts.

    For example, a paragraph will be inserted along with the rest of the template if the To field contains a specific domain and the subject contains a specific word or phrase, or the To field contains the same domain and the message body contains another specific word or phrase.

    An example of a complex condition

    Adding a condition based on the WhatToEnter macro result #

    1. In the template you’re creating or editing, right-click a part where a condition is needed: a paragraph, list, list item, table, or table row.

    2. Select an option that adds a condition.

      Adding a condition to a paragraph in a template that contains the WhatToEnter (WTE) macro
    3. Define the condition:

      • Under Find in, select WhatToEnter result.

      • Choose a WhatToEnter macro (the macro for creating custom input fields) to check for the condition. There must be at least one WhatToEnter macro in your template.

      • Select the condition (contains, doesn’t contain, contains any of, contains none of, is equal to, is equal to any of, is equal to none of, is empty, is not empty, matches regex, or doesn’t match regex).

      • Enter the text or regex to look for.

      When you’re done, select OK.

    4. In your template, a green indicator shows the section that the condition is applied to. Select Save.

      A green indicator in a template that contains the WhatToEnter (WTE) macro

    When inserting the template into an email message, you’ll see a dialog prompting you to select or enter some data. As soon as you do that and click OK, the data you’ve selected or entered (the WhatToEnter result) will be checked for the condition you defined.

    An example of a dialog shown by the WhatToEnter (WTE) macro

    If the condition is met, the part that the condition is applied to will be inserted into the email message along with the rest of the template.

    The template part is inserted because the condition is met.

    Nested Insert-if sections #

    To add another condition within an Insert-if section, do the following:

    1. Right-click a paragraph, list, list item, table, or table row inside the Insert-if section and select an option that adds a condition.

    2. A green indicator will appear inside the Insert-if section, indicating the presence of a nested Insert-if section. Select Save.

      An Insert-if section nested within another Insert-if section

    How to change a condition #

    1. Right-click an Insert-if section and select Change condition.

      The Change condition option
    2. Make the necessary changes, and then select OK.

    3. Save the template.

    How to remove a condition #

    1. Right-click an Insert-if section and select Remove condition.

      The Remove condition option
    2. Save the template.