Author: Ayush Chauhan, Data Engineer
In this article, we will see how to automatically save the attachments associated with an Outlook Mail to Azure File Share using Microsoft Flow. This helps to archive the Outlook attachments.
To optimize the attachment extraction from email to further optimize the performance of your entire solution you need to:
- Access the Microsoft Flow portal: https://flow.microsoft.com/ and sign in with your account
- In microsoft.com, select “My flows” in the top navigation bar, and then select “+ Create from blank” to create a Flow from scratch.
- On the “Create a flow from blank”, select “Create from blank” to start the process of creating an empty Flow.
Configure the Email Connector
- On the Flow designer, on the Trigger event enter “Email” and select the option “Email – When a new email arrives”.
We want that all the email received with a particular email id will trigger this flow, so on the Email Trigger configuration:
- Confirm that “Inbox” is configured in the “Folder” property
- Specify the filter, if the case is such all emails that have come from a specific email id in “from”.
- And confirm that the “Include Attachments” property is set to “Yes”.
Be aware that “Has Attachments” is a Boolean attribute that allows you to define if you want to receive only emails with attachments or not. This is the first filtering rule since we are looking for emails with Surveys in attachments. “Include Attachments” property is another Boolean this one allows you to specify if you indeed want to retrieve attachments along with the email.
Set global variables
- Just to avoid having multiple actions with the same configuration in different conditions branch, which may lead to mismatch configurations, we will be using variables, nevertheless, this is optional.
-
- Add the next step by clicking the “+New step” button and then choose the “Add an action” option
-
- Go to the “Choose an action” window, enter “Apply to each” and select the action, along with entering “attachments” in “Select an output from previous steps”.
-
- Now within the ‘Apply to each’ action creates another action, where you have to search for Azure File Storage and select “Create File”
Setup the Content
- Specify the folder in which you want to store the file.
- On the “File Name” property, select from the list of tokens the “Attachment Name” token from the “When a new email arrives” trigger.
- On the “File Content” property, select from the list of tokens the “Attachment Content” token from the “When a new email arrives” trigger.
Finally, save the file by clicking ‘save’ at the upper right-hand corner and test it to validate the flow. And once is triggered, it will copy the attachment to an Azure File Storage folder.
Wrap Up
This blog helps to automate certain processes in extracting the attachments in a simple and time-efficient way with Microsoft Flow. Hence, it doesn’t take much to write a heavy code. Hope this helps!