How to add contextual attachments from OneDrive

With Shared Email Templates for Outlook

With Shared Email Templates for Outlook, you can easily automate adding attachments to your email messages by using either the Message attachments feature or the ~%Attach macro. The How to attach files to your templates help page will guide you through the specifics of attaching files from OneDrive, SharePoint, and URLs.

If you're aiming to choose from several preselected files that you have on your OneDrive, you'll need a solution that is slightly more sophisticated since there are two macros involved: ~%Attach and ~%WhatToEnter. To get the desired result, follow the steps described below.

  1. Create a simple dataset. Fill in one of the dataset columns with file names.
    This is how your dataset might look like.

    Note. Each file name must be followed by the file name extension.

    Note. All the files that are going to be used as attachments must be in the same OneDrive folder.

  2. Start editing your template and place the cursor where you'd like to put the ~%Attach macro. Then click Insert macro:
    The Insert macro icon in the template editor
  3. In the search box, enter "attach from OneDrive" and select the corresponding option that will appear on the Shared Email Templates pane:
    Attach from OneDrive
  4. Select any of the files that you're going to attach and copy a link to it by clicking the Copy link icon:
    Copy a link to your file.

    To finish inserting the ~%Attach macro into your template, click Select.

  5. The ~%Attach macro placeholder appears in your template. Right-click the macro placeholder and select the Edit Macro Text option:
    Start editing the macro text.
  6. In the ~%Attach macro text, select and delete the "fileName", "driveId", and "fileID" parameters:
    Delete the selected parameters.
  7. Enter the "filePath" parameter and the link you copied in quotation marks. Then click Save:
    Add the filePath parameter.
  8. Now, it's time for the ~%WhatToEnter macro to show up in the text of your template just for a while. Click Insert macro and select What to Enter. In the macro dialog, opt for Dataset, type in some relevant title, and select both the name of the dataset you've created and the name of the column that contains the file names. Then click Insert:
    Insert the ~%WhatToEnter macro into your template for a while.
  9. The ~%WhatToEnter macro placeholder appears in the text of your template showing the name of the specified dataset and the name of the specified column. Right-click the macro placeholder to copy the macro text to the clipboard:
    Copy the ~%WhatToEnter macro text.
  10. Right-click the ~%Attach macro placeholder and opt for Edit Macro Text. In the ~%Attach macro text, delete the file name, along with the file name extension, and paste the copied ~%WhatToEnter macro text instead. Then click Save:
    The copied ~%WhatToEnter macro text in the ~%Attach macro
  11. Remove the ~%WhatToEnter macro that you added in Step 8 and can still see in the text of your template. Then save your template.

When you paste such a template into an email message, a dialog will show up so that you can choose an attachment:
Decide what to attach.
As soon as you make your choice, select the necessary file, and click OK, the template will be inserted and the file you've selected will be attached to the email message:
The selected file is attached.

So, by using the ~%WhatToEnter macro nested into the ~%Attach macro in the HTML code of your template, you'll be able to choose any attachment you like (from those preselected, of course):
Select the necessary attachment easily.

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