Inserting a picture from preselected OneDrive folders

With Shared Email Templates for Outlook

Adding an image to the body of an email message doesn't seem like a big deal, especially if you use the ~%InsertPicture macro ;) But what if you have several groups of images located in several folders on your OneDrive and want to firstly select a folder and only afterwards to decide which of the images it contains to insert, what then? Sounds like a touch of interactivity is badly needed, doesn't it? :)

In Shared Email Templates, you can create a dialog with two dropdown lists displayed one below the other: the first dropdown list will contain the names of the folders where you want to look for the images to be inserted and the second one will be for the names of the image files themselves. So you'll be able to choose both a folder and an image that is stored in it, provided that the image file names are the same for each folder. Such a dialog will make your template truly interactive. Let's see how to build it in a template.

Note. This is a master level "recipe" :) Perhaps your task can be solved much more easily. If you feel like asking us for help, just let us know by leaving a comment at the bottom of this page or sending an email to

The first thing you need to do is create a simple dataset that will contain the names of your OneDrive folders and their full paths. To add a path of a folder to your dataset, click the Insert Macro icon in a dataset cell:
The Insert Macro icon is here.

The Select macro sidebar will appear in your browser. Enter "insert picture from OneDrive" into the search box there and select the option you'll see:
Insert Picture from OneDrive

Choose any of the folders that you're going to add to the first dropdown list and click the name of any file that is located there. Then click the Copy link icon:
The Copy link icon

The full file path will be copied to the clipboard. Paste it into your dataset, and then delete the file name and the file extension. By doing this, you'll convert the file path you copied into the folder path you need.
A sample folder path in a sample dataset

Finally, your dataset will look like in the screenshot below:
A dataset is ready.

Now, when your dataset is ready, it's time to put two of the Shared Email Templates macros into play: ~%InsertPicture and ~%WhatToEnter.

  1. Start editing your template to add the ~%InsertPicture macro to it (see How to add a macro to your template). When inserting the macro, select Insert Picture from OneDrive, choose any image file that you're going to use for your email messages, and copy its link by clicking this icon:
    The Copy link icon
  2. As soon as you click Select and then Insert, the ~%InsertPicture macro placeholder will be added to your template. Right-click the macro placeholder and select Edit Macro Text:
    The Edit Macro Text option
  3. In the macro text, replace the "fileName", "driveId", and "fileId" parameters that you'll see there with the "filePath" parameter. Next to "filePath" (right after the colon), paste the copied link and make sure that it's surrounded by double quotation marks like shown in the screenshot below. Then click Save:
    The filePath parameter
  4. Click the Insert macro icon again to find and select What to Enter. In the ~%WhatToEnter macro dialog that will show up, opt for Dataset, enter the text you want to see above the first dropdown list, choose the dataset you've just created, and specify the column containing the folder paths. Then click Insert:
    Insert ~%WhatToEnter.
  5. The ~%WhatToEnter macro placeholder will appear in the text of your template. Right-click the macro placeholder and select Copy Macro Text to Clipboard:
    The Copy Macro Text to Clipboard option
  6. Right-click the ~%InsertPicture macro placeholder and select Edit Macro Text. In the "filePath" parameter, delete the part of the file path that comes before the file name but keep the first and last slash characters between which the part to be deleted sits:
    Continue to edit the ~%InsertPicture macro text.
  7. In place of the part you've just deleted, put the copied ~%WhatToEnter macro text. Make sure there's a slash before and after it. Then click Save:
    The ~%WhatToEnter macro in the filePath parameter
  8. In your template, delete the ~%WhatToEnter macro placeholder you added in Step 4. Then insert another ~%WhatToEnter selecting Dropdown list and specifying the image file names and extensions:
    One more ~%WhatToEnter to add

    Note. Make sure that the image file names are the same for each folder.

  9. Right-click the ~%WhatToEnter macro placeholder and opt for Copy Macro Text to Clipboard:
    Copy the text of the second ~%WhatToEnter macro.
  10. Right-click the ~%InsertPicture macro placeholder to select Edit Macro Text. From the "filePath" parameter, remove the image file name and extension:
    One more change is needed.
  11. Instead of the deleted image file name and extension, insert the copied ~%WhatToEnter macro text. Click Save:
    Nesting the second ~%WhatToEnter

    Then delete the ~%WhatToEnter macro placeholder that you added to your template in Step 8.

And don't forget to save the template, of course :) When you're pasting it into an email message, the trio of the macros will start performing to make the embedded dialog show up:
A dialog created with ~%InsertPicture and two nested ~%WTEs

So you'll easily select the necessary folder and image. Well done, isn't it? ;)

See also

How to insert contextual images into your emails

Post a comment

Seen by everyone, do not publish license keys and sensitive personal info!

If you have any questions or issues with this add-in, please feel free to post your concerns in the comments area. As soon as we answer, a notification message will be sent to your e-mail. If you do not want to share your thoughts in public, please contact us at