For this post, we’ll explore how to retrieve email information and attachments from previously saved email files (.eml or .msg). Saved email files stored in SharePoint or OneDrive (or any other location) don’t expose any useful metadata as standard, so we need to extract this information from the files themselves (To, From, Subject, etc.). This can be achieved using Encodian Flowr!
We will be using two Flowr actions:
Consider the following common scenario: important emails have been manually saved into a SharePoint folder called ‘Archived Emails’. The users now need to access information and contain attachments from the archived emails on-demand.
We’ll create a Power Automate flow to extract email information and attachments, which will be saved within a SharePoint list and then marked against the document in the document library to prevent future duplicate entries.
I’ve added a new column called ‘Information Extracted’ to the ‘Archived Emails’ document library. The ‘Yes/No’ column will be used to track whether information and attachments have already been extracted and added to the ‘Archived Emails Details’ list. A user can still run the flow when the column is set to ‘Yes’. Logic will be added to the Power Automate flow to prevent duplicates from being added to the list.
This is the ‘Archived Email Details’ list:
The Power Automate flow must be created in the default environment because it uses the SharePoint trigger ‘For a selected file’. If this trigger action is used outside of the default environment, the SharePoint user interface will not render the flow.
Using this trigger doesn’t give Power Automate much information about the selected file, so we need to use ‘Get file properties’ with the ID provided from the trigger.
Once we have the file properties, we can check whether the email information has already been extracted using a condition. If the ‘Information Extracted’ property is set to ‘true’, the flow will terminate to stop a duplicate entry from being added to the list. If the property equals ‘false’, the next action used is ‘Get file content’ to get the actual file content of the document.
Once we have the file content, we can use Flowr’s ‘Get Email Information’ action!
Now that we have all the email information, we can create the list item in SharePoint using the ‘Create item’ action.
The ‘Get Email Information‘ documentation contains a complete list of available properties.
Next, we need to check if the saved email contains any attachments. We can use the ‘Has Attachments’ property provided by the ‘Get Email Information’ action. If the email has attachments, we can then use the ‘Get Email Attachments’ Flowr action.
The ‘Get Email Attachments’ action will extract any attachments from the email message. Setting ‘Get Inline Attachments’ to ‘No’ means that any images in an email signature will not appear in the action’s results, preventing unwanted files from being saved to the SharePoint list.
Next, we will loop through each detected document and attach it to the SharePoint list item.
To finish the flow, we will update the ‘Information Extracted’ field on the source file within the SharePoint document library by setting the value to ‘Yes’.
Let’s run the flow for the Classified Information email.
This is what the .eml file looks like:
The email details have been added to the details list correctly:
Save time with 185+ actions across 9 connectors
Sign up for your free 30-day trial; no cards, catches, or contracts.
Don’t struggle! Try out our Premium Support packages today.
Technical Evangelist