Shared Email Templates for Microsoft Outlook

How to dynamically insert images with identical names from different OneDrive folders

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 same name images located in several folders on your OneDrive and you want to firstly select a folder and only then to decide which image to insert? Don't you think that a touch of interactivity is badly needed? :)

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.

Create a dialog to select a folder and an image in it

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 support@ablebits.com.

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 Select macro sidebar will appear in your browser. Select Insert Picture from OneDrive.
The Insert Picture from OneDrive option

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 the dataset cell, 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 folder path in a dataset cell

Finally, your dataset will look like in the screenshot below. Save the dataset.
Saving a simple dataset

Now it's time to add a dialog with two dropdown lists to your template. You'll need to put two of the Shared Email Templates macros into play: InsertPicture and WhatToEnter. These are the steps to follow.

  1. Start editing your template, choose a place for a picture, place the cursor there, and click the Insert picture button on the template editor toolbar.
    The Insert picture button
  2. Select Insert Picture from OneDrive, choose any image file that you're going to use, and copy its link by clicking the Copy link icon shown in the screenshot below. Then click Select and OK.
    The Copy link icon
  3. The InsertPicture macro placeholder will be added to your template. Right-click the placeholder and select Edit Macro Text.
    The Edit Macro Text option
  4. In the macro text, delete the "fileName", "driveId", and "fileId" parameters. Then click Save.
    The Edit Macro Text option
  5. On the template editor toolbar, click the Insert macro icon. Then select What to Enter. In the What to enter dialog that will show up, opt for Dataset. Then specify the field name by entering the text you want to see above the first dropdown list. Choose the dataset you've just created and the column that contains the folder paths. When you're done, click OK.
    Inserting the WhatToEnter macro
  6. The WhatToEnter macro placeholder will appear in the text of your template. Right-click the placeholder and select Copy Macro Text to Clipboard.
    The Copy Macro Text to Clipboard option
  7. 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.
    Editing the InsertPicture macro text
  8. 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
  9. In your template, delete the WhatToEnter macro placeholder that you added in Step 5.
  10. Another WhatToEnter is needed. When inserting it, select Dropdown list as its type, then enter the field name (it will be above the second dropdown list in the dialog), and specify items—image file names along with their extensions.
    One more WhatToEnter to insert

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

  11. Right-click the WhatToEnter macro placeholder and select Copy Macro Text to Clipboard.
    Copying the text of the WhatToEnter macro
  12. Right-click the InsertPicture macro placeholder and select Edit Macro Text. In the "filePath" parameter, delete the image file name and extension.
    The part to be deleted
  13. Instead of the deleted image file name and extension, insert the copied WhatToEnter macro text. Then select Save.
    Adding the second WhatToEnter to the filePath parameter
  14. Delete the WhatToEnter macro placeholder that you added to your template in Step 10.

And don't forget to save the template, of course :)

When you insert such a template into an email message, the trio of the macros will start performing to make the embedded dialog show up.
A dialog for selecting a folder and an image

By using the two dropdown lists that the dialog contains, you'll easily select the necessary folder and image. Well done, isn't it? ;)

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 support@ablebits.com.