How to create dynamic Outlook email templates for the current user

Aksana Pachkouskaya by , updated on

On reading this blog post, you'll learn how to automatically switch images, attachments, and text in a shared Outlook template, depending on the current user.

Let's say, you have a really nice template, and your teammates would be happy to use it in their correspondence, but you're stuck on making this template dynamic. The problem is that each of your colleagues would like to get a different image, an individual attachment, and some specific text added to the template every time they use it. So, when the template is going to be pasted into the email body by another person, all this stuff should change automatically.

Do you think that such a task is too difficult? Nothing of the kind ... for our smart Shared Email Templates add-in :) Just a few steps to take, and a dynamic Outlook template for your team will be ready.

Step 1. Prepare your Excel table

First, make sure you have all the necessary variables in one and the same Excel table stored, say, in OneDrive. How would you do that? Check both the structure and the content of your table:

  1. The leftmost column of the table should contain your colleagues' email addresses. They will be sort of reference points for Shared Email Templates. Using them, the add-in will be able to find the right image, attachment, and text for each person.
  2. All the other columns are reserved for the items that will be dynamically inserted into an email. I mean pieces of text and links to files that your teammates are interested in. Be sure to create these links with the Shared Email Templates add-in as described below, otherwise they won't work the right way.

Step 2. Generate proper content for the table

At this stage, your table may be like this one:
This is an example of your Excel table.
The email addresses, which your teammates' Shared Email Templates accounts are registered to, are in column A. The email addresses in my screenshots are imaginary—just to give you an example :)

Column B ('Image'), column C ('Text'), and column D ('Attachment') are still empty and have to be filled. Let's get proper data for them.

Images to insert: How to get a link that will work

  1. Run Shared Email Templates.
  2. Click the New Template button, and then click the Insert Macro icon.
  3. You'll see a list of all the macros the add-in has. Find and pick this one: ~%InsertPictureFromOneDrive.
  4. Select a file that contains one of the images you would like to swap.

    Note. Don't forget to share these files beforehand. Otherwise, your colleagues won't have access to them.

  5. Fill in the boxes of the Insert picture dialog window (the way you need) and click Insert.
  6. Find the View HTML and View Template Content icons on the editor toolbar. They are neighbors :) Click any of them:
    Here are the icons to click.
  7. Select and copy the ~%InsertPictureFromOneDrive macro along with the link created:
    Copy the selected line.
  8. Paste the copied line into your Excel table.

    Note. Make sure that the email address of your teammate who the image is intended for is in the same row:

    Add the copied line to your Excel table.

  9. Get links to other images in the same way and paste them in the corresponding rows:
    This is how the filled column looks.

Text to add: How to arrange it properly

Now, it's time to deal with text.

If you're happy with plain text that has no formatting at all, simply type the required extracts one by one in an individual cell each (on the right of the corresponding email address, of course). The add-in will bring this text to your template as is.

Would you rather get some phrases bold, colored, or printed in italics? If so, format them with standard HTML tags or let the add-in do that for you. Here's how:

  1. Create a new template by clicking the New Template button.
  2. Type the text that any of your colleagues needs and format it with icons on the editor toolbar:
    Format a piece of text the way you need.
  3. When you're done, click the View HTML icon to copy the lines you'll see in the View HTML window:
    Copy HTML.

    Tip. You can also copy these lines from View Template Content.

  4. Insert the lines into your Excel table. Don't forget that they should be in the same row as the email address of the person who is interested in using this text:
    Paste the copied lines into your Excel table.

    Tip. If there are line breaks in your text, select the cell of interest, and paste the text directly into the formula bar to avoid splitting.

  5. Fill the rest of the column likewise:
    The filled column may look like this.

Files to attach: How to get a link that will work

As for the files that should be attached, process them with the ~%AttachFromOneDrive macro:

  1. Run Shared Email Templates and click New Template.
  2. Go to the editor toolbar, click Insert Macro, and select ~%AttachFromOneDrive.
  3. Find and pick one of those shared files that your colleagues would like to attach.
  4. Click View HTML or View Template Content.
  5. Select the ~%AttachFromOneDrive macro whole—from the tilde to the closing square bracket:
    Select and copy the macro.
  6. Copy and paste the selected line to your Excel table:
    Insert the copied line into your Excel table.
  7. Do that for all the files of interest:
    Here is the column that is already filled.

Step 3. Create a dataset from your Excel file

Convert your Excel table into a Shared Email Templates dataset. Here are the detailed instructions: Connect Excel table.

Step 4. Make your Outlook template dynamic

Finally, your dataset is ready, and all you need do is modify your template.

How to add an image for the current user

Let two macros of ours—~%DatasetValue and ~%ProfileProperty—work for you :)

  1. Find the existing template you want to make dynamic and open it in the Edit mode. (Or create a new template from scratch, if you like.)
  2. Decide where exactly the changing image will appear and place the cursor there.
  3. Click the Insert Macro icon and pick ~%DatasetValue from the list.
  4. In the macro's dialog window that you'll see, do the following:
    • Choose the necessary dataset ('NewTeam_members' in my case).
    • Pick the column containing the values to be returned (in my Excel table, it's 'Image').
    • Select any item under "Key value" to delete it and type "~%ProfileProperty[EmailAddress]" instead.
      Take a look at the macro's dialog window.
  5. Click Insert and Save.

Congrats! :) You've just nested the ProfileProperty macro within the DatasetValue one. Would you like to know what for? :) The ProfileProperty macro will bring the current user's email address and thus 'point out' the right direction for the DatasetValue macro. In its turn, the DatasetValue macro will track down the right cell in your dataset and fetch the image of interest that the ~%InsertPictureFromOneDrive macro returns.

How to add certain text for the current user

The way of providing the current user with a specific piece of text doesn't differ substantially from getting a different image for them:

  1. Go back to editing your template to insert the ~%DatasetValue macro again.
  2. In the Dataset value dialog window, select the needed dataset, choose the column with text fragments (I'll opt for 'NewTeam_members' and 'Text'), and pick any line in the Key value drop-down menu to replace it with "~%ProfileProperty[EmailAddress]":
    View the filled boxes of the macro's dialog window.
  3. Insert the macro and save your template.

From now on, the macros operating in coalition will easily find the email address of the current user in the specified dataset and return the text this colleague of yours needs.

How to add an attachment for the current user

With practiced ease :) insert one more DatasetValue macro in the text of your template. This time, it is necessary for bringing an individual attachment to each user.

  1. In the Edit mode, click Insert Macro and choose ~%DatasetValue.
  2. Fill in the boxes of the macro's dialog window picking the right dataset (I'll pick 'NewTeam_members'), selecting the column with the ~%AttachFromOneDrive macros in it (I'll select 'Attachment'), and putting "~%ProfileProperty[EmailAddress]" instead of any item from the Key value list:
    Interact with the macro by filling in the required boxes.
  3. Click Insert and save the template.

Good to go :)

Hooray—your dynamic template is ready :) The part you've just modified may look like this:
This makes your template dynamic.
If I'm the current user, the template pasted into the email body will include the below attachment, image, and text:
This is a pasted dynamic Outlook email template for the current user.
If it's my colleague Alex who is the current user, the same set of macros will bring another combination of inserted items for him:
The current user has changed, and the pasted Outlook email template has changed too.
If the current user is my colleague Kate, the inserted attachment, image, and text will be as follows:
Here is one more change of the pasted dynamic Outlook email template.
Now you know the secret to creating dynamic Outlook email templates and can tell it to your colleagues. Or ... you can keep it and become indispensable for your team ;)

Available downloads

Why Shared Email Templates? Top 10 reasons (.pdf file)

You may also be interested in

Table of contents