Table of Contents
Use Microsoft Flow for handling Email
Summary: How to use Microsoft Flow (Power Automate) to automatically handle email.
Date: Around 2020
Refactor: 1 March 2025: Checked links and formatting.
On this page you'll see the flows I created for automatic email handling. The following functionality is used:
- Detect a new mail in a shared Office 365 email box
- Check for advanced options in the email like sender address, subject and if the email has an attchment
- Get the attachment and save it in Sharepoint Online
- If the folder dows not exist, create it with a name like year-month format
- Use a condition on the body part of the email
- Save an email on SharePoint Online with the current date in the filename
- Mark the email as red
I used two flows for this.
Trigger
Action 1 - Save Attachment
The first flow saves the attachment on a location in sharepoint online:
When creating a file on sharepoint, if the folder does not exist, follow these steps to have SharePoint automatically create the folder for you:
- At the site address, Choose to enter a custom value like: https://getshifting.sharepoint.com/teams/ICT/
- Be sure to add a / at the end of the address
- Then in the folder path, enter the folder structure as it should be, including the new folder and be sure to remove any trailing /
Currently, adding and removing / does not seem required anymore. It just works now.
It is possible to have a custom name depending on the date, use the expression option for that and use an expression like: formatDateTime(utcNow(), 'yyyy-MM-dd')
.
Action 2 - Save Email
Depending if a specific line in the subject of the mail is found, the mail gets saved to sharepoint and marked as read, or is only marked as read:
Action - Do not save .png Attachments
When handling html email sometimes signatures (or included html objects) are also handled. Based on your specific files you can skip these files so they do not get saved. See below the start of a flow that skips attachments with the “Attachment Name” that contains: .png
:
Useful Links
- See https://docs.microsoft.com/en-gb/dotnet/standard/base-types/custom-date-and-time-format-strings for more options on using date and time strings.
- https://docs.microsoft.com/en-gb/learn/browse/?products=bizapps-flow for more training on Microsoft Flow!