Microsoft flow helps to automate lot of our day to day activity and keep things simple and easy. In this Article, we are going to discuss how to create a SharePoint flow for the Outlook mail. If the mail has attachment, then the below flow steps helps you to save the attachments and store the eml file of the mail.
Microsoft flow is designed in a way that anyone can use it without technical knowledge just by few clicks to apply conditions and steps. Let’s jump into the implementation,
Step 1: Assign flow for arriving new emails in Inbox
Go to Microsoft flows and choose “Create from blank” option in your Flow.
Select the “Office 365 Outlook When a new email arrives (webhook)“ from the dropdown of Triggers to make flow for new emails which arrive to Inbox of the Outlook.
Then choose “Inbox” from Folder to make flow for new Email which arrive to Inbox.
Click ‘Show advanced setting‘ and change Has Attachment‘ as yes to create a condition for the flow.
This condition helps to process only the emails with attachment. If the mail has an attachment and then move for the next action. If the condition fails, the flow will not perform.
Step 2: Get the email which have attachments
- Then Choose ‘New step’ and select the ‘Add an action’ option.
- Select ‘Office 365 Outlook’ icon from Connectors and choose Office 365 Outlook – Get email option.
- This action helps to get email from the Inbox.
- Choose ‘Message Id’ for Message Id and make ‘yes’ for Include Attachments.
Step 3: Assign subject of the mail to a variable
Next, initialize a Subject variable and then give name and assign the type as ‘string’ and choose ‘Subject’ as value for variable. The subject of the email assigned to the variable in this action.
Step 4:â€¯ Create an array with unwanted regular expressions
Then, create an array and assigned full of regular expressions in the array. This action will help for the further process.
Click Add Dynamic content and move to Expression then import the following code to create array for the unwanted regular expressions in the Expression to remove from subject and give a name for folder as subject of the mail.
Step 5:Replace the regular expression while create folder with name of mail subject
Replace the regular expressions as null because regular expressions which make issue while creating folder in site.
Then assign the output of the replaced value to the Subject variable. To replace the regular expressions, click Add Dynamic content and move to Expression then import the following code in the Expression to perform the action.
Step 6:Push the attachments in the SharePoint library
Next, choose SharePoint icon from the collector and select ‘SharePoint “ Create a ‘file’option from action.
And give site address to store file in the SharePoint library. In the folder path, give the folder name and give the file name as their subject to create for every file for their attachment. Use ‘take’ expression to set limitation for name of the file.
Then File Name is chosen as Name and File Content as content. This action make push the attachment in the file and named as their attachment name.
Step 7: Get the message of the mail
Choose ‘Office 365 Outlook from collector and ‘export email’ option from action.
Choose ‘Message Id’ for Message Id.
Step 8: Push the email file in the SharePoint library
Then, choose SharePoint icon from the collector and select ‘SharePoint “ Create file’ option from action.
Give site address to store file in the SharePoint library. In the folder path, give the folder name and give the file name as their subject to create for every file for their attachment. Use ‘take’ expression to set limitation for name of the file.
Then File Name is chosen as a Subject and then give .email to create email file. File Content as body to assign body of the email. This action helps to push the email file to the folder.
I hope you learnt how to apply flow in your SharePoint flow for the Outlook mail.