Conditional formatting for Outlook email templates

With dozens of Outlook emails coming weekly, your addressee can probably take just a very quick look at each of them. Picking a bright font color for the phrases that should be noticed for sure may be a good idea in such a case.

This article will explain how to automate the process of changing the font color of a paragraph, a sentence, a word, a list item, or a table cell value with a combination of a macro and a few HTML tags when using Shared Email Templates. Do not worry if you are new to the add-in and have never heard of macros before. You will be guided every step of the way :)

What we are going to do...

Suppose you need to send three similar reminders saying that your addressees should submit their projects on time. The first email is to reach them 14 days prior to the deadline. The second one has to be delivered a week after. The final reminder must be sent the day before the deadline. You are going to keep the text absolutely the same except for the time phrase. And you would like that phrase to be colored brightly and the font color to vary depending on the time left:

Dear all,
I am writing to remind you about the deadline for your projects. You should be done with them in 14 days / in 7 days / tomorrow.

Can we create an Outlook email template that will make such 'conditional formatting' possible? Sure. Here it is:
A sample template for Outlook emails

How can we do that? Let's keep this question open for a while and start with simpler tasks to get practiced first :)

How to color a piece of text in a template

Primarily intended for adding the necessary elements into the email body, the ~%WHAT_TO_ENTER macro can also be helpful in creating a handy palette that will let you switch instantly from one font color to another. You can make use of the macro to get a piece of your text colored with any of your favorites like in the screenshot below:
A colored piece of text in the email body

To achieve such a result, modify a template by taking two steps with a few sub-steps each.

Step 1: create a dropdown list with colors

  1. In your list on the Shared Email Templates pane, pick any template you are ready to experiment on.
  2. Open it in editing mode by clicking Edit or Edit in Browser.
  3. Decide what piece of your text you would like to color, stand the cursor before the very first symbol of it, and click the Insert Macro icon.
    Add a macro to an email template.
  4. In the drop-down menu that you will see, find the ~%WHAT_TO_ENTER macro. Click it to get the What To Enter window open and start working with the macro settings.
  5. Select Dropdown list, fill in Window title (with 'Color', for instance), and type color names under Items. Here you go:
    Create a dropdown list with your favorite colors.
  6. Do not forget to click Insert afterwards - it is key :)

The ~%WHAT_TO_ENTER macro will appear in the text of your template:
A macro in an email template

What we have now is really important, but it is just half the battle :) Editing the HTML code is needed as well.

Step 2: edit the HTML code of a template

  1. Get the HTML code window open by clicking the View HTML icon.
    Click the View HTML icon to see the template's code.

    Editing becomes possible.
    View the HTML code of your template.

    The process itself resembles doing a jigsaw puzzle at a stage when you are almost done but still have some pieces to fit :)

  2. Place the ~%WHAT_TO_ENTER macro and the piece of your text the coloring options are intended for between the <span> tags:<span~%WHAT_TO_ENTER[blue;green;red;{title:"Color"}]>piece of text</span>
  3. Add data-set-style="color: before the macro tilde:<span data-set-style="color:~%WHAT_TO_ENTER[blue;green;red;{title:"Color"}]>piece of text</span>
  4. Insert ;" right after the macro closing square bracket:<span data-set-style="color:~%WHAT_TO_ENTER[blue;green;red;{title:"Color"}];">piece of text</span>
  5. Replace the double quotes in {title:"Color"} with the single ones: {title:'Color'}.<span data-set-style="color:~%WHAT_TO_ENTER[blue;green;red;{title:'Color'}];">piece of text</span>

    Finally, the edited HTML code lines should be as follows:

    Here is the <span data-set-style="color:~%WHAT_TO_ENTER[blue;green;red;{title:'Color'}];">piece of text</span> I'd like you to pay attention to.

    It is always a good idea to double-check for typos.
    Double-check the edited code for typos.

  6. Now, when you are done with the HTML code, click OK and Save. Your template is ready to use.

Likewise, you can make it possible to pick a favorite color for any piece of the text in your template, including a paragraph, a sentence, a word, a list item, and a table cell value.

Note. If you see the following error on clicking Save, it is most likely that you have not switched to the single quotes in {title:"Color"} and it is necessary to rewrite the code line.

An error message

How to color a paragraph

To get the whole paragraph colored, you need to put the cursor before the very first character of the target paragraph, insert the ~%WHAT_TO_ENTER macro, put your palette on the macro dropdown list, and edit the HTML code of your template by following the steps described above. The modified code lines should be similar to the ones highlighted in the screenshot below:
Check the modified code for typos.

If they are error-free, on double-clicking the ready template, you will gain access to the palette you have just created.
A dropdown list with colors

Pick any color you like and get the text of your template pasted into the email body.
A colored paragraph in the email body

How to color a sentence

The process of getting a single sentence colored with any of your favorites does not differ from that of a paragraph. If all is done correctly, the corresponding extract of the HTML code of your template will be as follows:
Do not forget to check for typos.

Do not forget to click OK and Save to keep the changes you have made. Here is the result to enjoy:
A colored sentence in the email body

How to color a word

Changing the font color of any word in the text of an email in the blink of an eye also requires putting your favorite colors on the list and modifying the HTML code of your template. Make sure that there are no typos in the edited code lines. Double-checking is never superfluous in such a situation.
Remember to check for typos.

If pasted into the email body, the template will look like in the screenshot below:
A colored word in the email body

How to color a list item

To make the solution workable for a bulleted or numbered list, follow the steps we have discussed earlier. Then double-check the edited HTML code lines. Here are the screenshots of interest:

Bulleted list
Check for misprints.

Numbered list
Check for errors.

The resulting text in your email will be similar to the following ones:
A colored bulleted list item in the email body

A colored numbered list item in the email body

How to color a table cell value

To provide you with a selection of font colors for accentuating a table cell value, the HTML code of your template should contain a line similar to the one highlighted in the screenshot below:
Check for mistakes.

If no mistakes are made in the process of modifying the template, the email body will get such a text:
A colored table cell value in the email body

How to conditionally format your Outlook emails

Now that you know the basics, we can go further and tackle the 'conditional formatting' problem :) Here is the text in question:

Dear all,
I am writing to remind you about the deadline for your projects. You should be done with them in 14 days / in 7 days / tomorrow.

To get three emails out of one and the same template with the coloring options available for the time phrase, we need to use the ~%WHAT_TO_ENTER macro twice. First, it should appear in the template as is (without any modifications) to let us choose between the time phrases. Then, it has to be used once again (in its modified version) to provide us with a set of font colors. Here are the necessary actions:

  1. Create a new template using the text from the screenshot below as an example.
  2. Stand the cursor at the very end of the incomplete sentence and add the ~%WHAT_TO_ENTER macro right before the period via the Insert Macro menu.
    Insert the first WHAT_TO_ENTER macro.
  3. In the What To Enter window, select Dropdown list and type in the time phrases. Add any Window title you like ('When', for instance).
    Create a dropdown list with time phrases.

    After you insert the macro, the template will be as follows:
    Take a look at the result.

    It is not ready yet and has to be modified.

  4. One more ~%WHAT_TO_ENTER macro is needed. Add it before the macro you already have.
    Insert the second WHAT_TO_ENTER macro.
  5. Arrange another dropdown list:
    Create a dropdown list with colors.

    At this stage, the text of your template will be like this:
    Check the result.

  6. It is time to start editing the HTML code. Anchor the macros between the <span> tags:<span~%WHAT_TO_ENTER[blue;green;red;{title:"Color"}]>~%WHAT_TO_ENTER[in 14 days;in 7 days;tomorrow;{title:"When"}]</span>.
  7. Insert data-set-style="color: before the first macro:<span data-set-style="color:~%WHAT_TO_ENTER[blue;green;red;{title:"Color"}]>~%WHAT_TO_ENTER[in 14 days;in 7 days;tomorrow;{title:"When"}]</span>.
  8. Add ;" after the closing square bracket of the first macro:<span data-set-style="color:~%WHAT_TO_ENTER[blue;green;red;{title:"Color"}];">~%WHAT_TO_ENTER[in 14 days;in 7 days;tomorrow;{title:"When"}]</span>.
  9. Use single quotes instead of the double ones in {title:'Color'}:<span data-set-style="color:~%WHAT_TO_ENTER[blue;green;red;{title:'Color'}];">~%WHAT_TO_ENTER[in 14 days;in 7 days;tomorrow;{title:"When"}]</span>.

    If modified correctly, the code lines will be as follows:

    You should be done with them <span data-set-style="color:~%WHAT_TO_ENTER[blue;green;red;{title:'Color'}];">~%WHAT_TO_ENTER[in 14 days;in 7 days;tomorrow;{title:"When"}]</span>.

    Compare with the screenshot below:
    Check for typos.

Click OK and save these changes. From now on, each time you double-click the template to insert it into your email, two dropdown lists become available within the same window on the Shared Email Templates pane letting you pick the time phrase and the font color of interest:
Pick the necessary time phrase and font color.

This is it :)

To be continued :)

Feel free to drop in for reading and commenting :)

Table of contents

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)