Power Automate: Save An Email Message To SharePoint

Power Automate: Save An Email Message To SharePoint

It is a common task to save a copy of an email message to SharePoint as backup. With Power Automate, we can save incoming/outgoing email messages and their attachments to a SharePoint Document library. We also have the option to place the email message in a folder or add metadata to make it easier to find later on.

Table of Contents
• Introduction: The Legal Department Emails ArchiveSetup The SharePoint Document Library To Hold EmailsConfigure The "When A New Email Arrives" Trigger SettingsExport And Save The Email To SharePointRun The Power Automate Flow To Save An Email To SharePoint

The legal department at an insurance company has conversations with outside counsel through email. A Power Automate flow is used to save incoming emails to SharePoint as an [.eml] file.



The saved emails can be re-opened in Outlook along with their attachments.




Setup The SharePoint Document Library To Hold Emails

Create a new document library named Legal Conversations in SharePoint. This document library will be where emails are saved to.




Configure The “When A New Email Arrives” Trigger Settings

Open Power Automate and create a new automated flow using the Office 365 Outlook – When A New Email Arrives In A Shared Mailbox (V3) trigger. Choose the Folder named Inbox.



Go to the trigger’s Settings and enable Split On. This tells Power Automate to evaluate each email individually as it arrives in the inbox.




Export And Save The Email To SharePoint

To get the email’s content we must export it. Insert an Office 365 Outlook – Export Email (V2) action and supply the Message Id from the flow’s trigger. Use the same shared mailbox address as the trigger does.

Note that the export email action only works with a shared mailbox.



Then add a SharePoint – Create File action to the flow. Target the Legal Conversations document library in the Folder Path. Use the received email’s subject as the filename followed by the extension [.eml]. Load the File Content property with the body of the export email action.




Run The Power Automate Flow To Save An Email To SharePoint

We’re done. Save the flow and perform a manual test by sending an email to the target inbox.



The flow will complete successfully and a new email will show in the SharePoint document library.



Open the email to view its contents. Attachments cannot be shown while in SharePoint. To do this, press the Download button then open the email file in Outlook.



The attachments are able to be opened now.





Questions?

If you have any questions or feedback about Power Automate: Save An Email Message To SharePoint please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest

34 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Fints
Fints
10 months ago

Thank you for this article. Is it the same use when emails arrive in a Teams channel? Thanks again

Fints
Fints
10 months ago

Thank you for the message.
In a Teams channel, you can get the email from the channel by clicking on (…) “get the email”. You can send an email and a message in Teams.

Rob
Rob
10 months ago

“Attachments cannot be shown while in SharePoint”

For us, this was a significant downside of saving the email as-is.

Instead, I created a flow sets up a folder for each email named “Email from <email address> <date and time>”, sets the title of the folder to the email subject, and saves the email body (as html) and each attachment to that folder. Most attachments can then be opened directly from SharePoint.

This runs from an app which allows the user to select emails to save, as we didn’t want to save every email coming in.

Yan
Yan
6 months ago
Reply to  Rob

Hi Rob, I’m very interested in implementing something similar to allow users to select emails to save. Could you please explain how you set your flow to achieve the functionality? Thanks in advance for your help.

David
David
1 month ago
Reply to  Rob

Hi Rob, any chance of sharing your method with us?

Omar
Omar
10 months ago

Cheers mate – very easy to follow – appreciate it

Wayne Wallace
Wayne Wallace
10 months ago

Loved it, Thanks for sharing!

Ian Irvine
Ian Irvine
8 months ago

Hi

enjoyed this article

I was stuck at the point where the export mail action had the message ID from the when a mail arrives in a shared mailbox action. It required me to enter the shared mailbox name, which seems really obvious when looking back.

Would have thought the action would have errored if the original mailbox was blank, but it still saves OK and runs fine till it reaches that action then just times out

Donna LaFrance
Donna LaFrance
8 months ago

Hi, thanks for the great tutorial. I have set up my flows according to your guide and it works perfectly. Can you let me know how to remove the “RE” and “FWD” when filing the email? This helps if i need to pull all emails on a subject.

Caroline
Caroline
8 months ago

Hi, I really need some help. I have followed the above steps but when I check the email that is saved in SharePoint, it doesn’t show the subject details or the body of the email in the preview or if I reopen it in Outlook. I must be missing something but not sure what. the From is blank. Sent on: is dated Monday, January 1, 0001 12:00:00 AM. To: is blank. Subject: is blank. No body.

Julie
Julie
8 months ago
Reply to  Caroline

I am getting the same error and don’t have the option to even open it in Outlook. I must be missing something too

Daniel Turack
23 days ago
Reply to  Caroline

Hi Caroline and Julie, I hope you were able to get a solution by now, but I had a maker ran into this same issue recently. It worked fine for me in the US region, but would come through blank for them in EMEA. After investigating I found that switching to the classic designer version of Power Automate and then re-adding the “body” variable to the last step resolves the issue. Hope this helps!

Sid
Sid
8 months ago

If we get reply email to the same subject, how do we store it in the same folder ?

Kareena Beniwal
Kareena Beniwal
2 months ago
Reply to  Sid

looking for the same

Alex
Alex
1 month ago

I added the original emails’ date/time key to the save file name. This should always work since the date/time goes down to the second.

m.Sidiqi
m.Sidiqi
6 months ago

Thank you for this details steps, It was exactly what i was looking for to move emails with Attachments to SharePoint automatically

Eugene
Eugene
4 months ago

Can you share your code view with us please?

Stuart
Stuart
4 months ago

Really useful and clearly explained, but this all works from the ‘incoming email’ trigger.
I have a workflow which already creates an outgoing message on completion, is there a way to save a copy of that email to SharePoint as part of the workflow? I only want it to move them for these workflow outputs (which can go to different email addresses), not a general all outgoing emails?

Thanks

Stuart Dare
Stuart Dare
4 months ago

This example uses the trigger ‘When A New Email Arrives’ is there a way to automatically save outgoing mails to SharePoint? E.g. I have an approval workflow which on completion sends an email to accounts to make a payment, I would like to save a copy of that email in the SharePoint folder where the invoice is saved?Thanks

Yanelis
Yanelis
3 months ago

Would the steps above work for saving outgoing emails. Would I just select the sent folder instead of inbox?

Kevin
Kevin
3 months ago

Disregard… answered my own question. 🙂

This article was AWESOME!!!!!

Last edited 3 months ago by Kevin
John Dempsey
3 months ago

Great article. Works perfectly.

Tazin Imran Dadan
Tazin Imran Dadan
2 months ago

Hi,
This seems very helpful. But my code is failing at the last step with the below error:

Action ‘Create_file’ failed: The API ‘sharepointonline’ returned an invalid response for workflow operation ‘Create_file’ of type ‘OpenApiConnection’. Error details: ‘The API operation ‘CreateFile’ requires the property ‘body’ to be of type ‘Object’ but is of type ‘String’.’

Olivia
Olivia
2 months ago

Hi, I need some help. Is there a way that I can attach an email as an msg instead of an eml? I tried to change the extension to msg, but it cannot be opened.

Thanks,

Kareena Beniwal
Kareena Beniwal
2 months ago
Reply to  Olivia

for me, the downloaded .eml file is empty, doesn’t contain anything

Kareena Beniwal
Kareena Beniwal
2 months ago

Hello Matthew, when i follow these steps, the downloaded email file is empty and doesn’t contain any text or attatchments

Alex
Alex
1 month ago

Copying this from above in case somebody comes up with a solution:

I am running into this same issue…

My best guess is that this is caused by trying to save folders from a personal email instead of shared mailbox. This is noted in the article, but does not explain why or what will happen if attempted. I am trying to come up with a workaround, but have not yet figured one out.

If anyone has a solution at this point, then it would be great if they could share it here! Thanks!

Daniel Turack
23 days ago
Reply to  Alex

Hi Alex, I’ve copied my comment from above to make sure you can hopefully use this solution. I was searching for an answer for this for awhile and finally just went in and tested everything I could think of until it worked.

I had a maker run into this issue recently. It worked fine for me in the US region, but would come through blank for them in EMEA. After investigating I found that switching to the classic designer version of Power Automate and then re-adding the “body” variable to the last step resolves the issue. Hope this helps!

Ben
Ben
1 month ago

I am getting this error too – how do I fix it please

Action ‘Create_file’ failed: The API ‘sharepointonline’ returned an invalid response for workflow operation ‘Create_file’ of type ‘OpenApiConnection’. Error details: ‘The API operation ‘CreateFile’ requires the property ‘body’ to be of type ‘Object’ but is of type ‘String’.’