In this Microsoft flow or Power automate tutorial we will discuss how to save my email attachments to a SharePoint document library Power Automate or flow. Let us see, a few examples of Power Automate save email attachment to SharePoint.
- Power Automate save email attachment to SharePoint library
- Power Automate save email attachment to SharePoint with different name
- Power Automate save email attachment to SharePoint list item
- Power Automate save multiple email attachment to SharePoint
- Power Automate save excel email attachment to SharePoint
Basically, it will save the attachments coming to my Office 365 email box. We will also see how to save email attachments from a particular person or from a particular email address to the SharePoint library through a flow.
If you are new to Microsoft flow of power automate I can check out an article that I wrote on what is Microsoft flow and how to start with Microsoft flow.
Power Automate save email attachment to SharePoint library
When we send an email with the attachment it takes a lot of internal space. To avoid this, we can store the attachment in a specified document library or folder of the SharePoint site and archive the mails. In this way, we can save internal space.
So for this, here we will create a Microsoft flow that will trigger when a new email will arrive with an attachment.
For this go to https://flow.microsoft.com and then click on + Create -> Instant cloud flow.
Then we will add another action under this trigger i.e. Apply to each. Here it will ask to select an output from previous steps. So we will add Attachment as output.
Again we will add an action inside the apply to each i.e. Create file(SharePoint).
Now our flow is ready to run. Let’s test it.
For testing, here we will send an email with an attachment from a testing user ID.
When we will click on the attachment it will store on the specified folder path.
This is how to save an important email attachment to the SharePoint document library.
Power Automate save multiple email attachments to SharePoint
Similarly, we will see how to save multiple email attachments to SharePoint. Now we will use this flow to see this requirement. For example, here we will attach multiple attachments such as images, PDFs, Word files, etc. in an email and that will send us from another user.
The flow will be exact the above one.
Since the flow already has the Apply to each block, so it will read all the attachments and save the attachments to the document library.
Once the flow triggers, you can see the multiple attachments are stored at a time in the SharePoint document library:
This is how to do save multiple email attachments to SharePoint using Power Automate.
Power Automate save excel email attachment to SharePoint
Now, let us see, how to save excel email attachments to a SharePoint library using Power Automate.
If the email has multiple attachments like (.xlsx, .pdf, .txt, .png, etc), it will only save the excel files (.xlsx or .xls).
For this, I have again created an automated flow (Go to https://flow.microsoft.com, then click on + Create -> then choose Instant cloud flow).
Here in the Appy to each block, first I have added one condition, that will check if the Attachment name contains .xlsx or .xls. These I have put in an Or condition.
If it is Yes, I am creating the file using the Create file flow action and if it is No, then we are not doing anything. You can check out the screenshot below:
Let’s test the flow by sending some attachments like excel files and word files from a test user to ourselves.
Once our flow run, we can see only the excel files are saved in the SharePoint document library (in the specified folder path).
This is how to save excel attachments to SharePoint using Microsoft flow. You can download this flow from here also.
Power Automate save email attachment to SharePoint with different name
Here, we will see how to save email attachments to SharePoint with a different name or how to rename the email attachment. For this, the following steps are:
On Power Automate, let’s trigger the flow by adding the trigger When a new email arrives(V3). Here we have to choose a folder where a new email arrives. So we will select ‘Inbox‘.
Now we will add an action to initialize a string variable that will use to rename the email attachment process.
In the next step, we will add an action as Apply to each loop. That will help to rename each attachment and save it to SharePoint.
In that loop, we will select output Attachments from previous steps. Inside that loop, we will add another action i.e. Set variable. Here, we will use the first variable that we have initialized i.e. VarName, and set the value as Attachments Name.
Inside that loop, next, we will add a compose to extract the attachment or filename using the below expression:
Similarly, we will add another Compose to extract the extension of the attachments or files name using the below expression:
Again, we will add another Compose action using an expression that will concatenate both the first name and extension of the attachment with a date i.e. on which date the attachment was received. For example, if we got an email attachment i.e. XYZ.png then it will be saved as XYZ-29112021.png.
For this, the expression is:
In the final step, we will add an action Create file under SharePoint that will create the modified file inside the specified SharePoint folder:
Now our flow is ready to run and test. Let’s test the flow by sending an attachment in an email to yourself:
It will save in different names having today’s date in SharePoint:
This is how to save email attachments to Sharepoint with a different name in Power Automate. For reference, here we have attached the whole flow. You can download this from here.
Power automate save email attachment to sharepoint list item
Here, we will see how to create a new item automatically and save email attachments to the SharePoint list.
For this requirement, there is a default template named ‘Create item and add attachments to a SharePoint list on a new email arrival‘ that is available on Power Automate.
Select the template and then click on Continue to create an automated flow:
To save the email attachments, we have created a SharePoint list like below:
Where, Title: a single line column
About: a multiline column
Let’s see how the flow works on flow and on SharePoint list:
First, we have to choose a folder to where the new email arrives. Then we have to insert the site address and SharePoint list name.
Similarly, in the Add attachment action, insert the Site address and List name:
Now our flow is ready to run. Let’s test it by sending an email with an attachment to yourself:
Now we can see, a new item is created and saved this attachment in the SharePoint list:
Send my email attachment to a SharePoint document library (using Template)
A lot of times you might require to save important email attachments to the SharePoint document library. Or maybe you want to save the attachments coming from a particular person like your manager or CEO or director.
So in this example, we are going to use the Microsoft flow template “save my email attachments to a SharePoint document library” to create a flow, that will save all the email attachments from everyone to the SharePoint library.
As well as I will show you how to specify a particular from address, and emails coming from that particular email address if contains attachments, then it will save to the SharePoint library.
Let us see how to create this flow.
Login to https://flow.microsoft.com and then provide your office 365 credentials to log in.
Once login in from the left navigation click on the Templates button And then search for the template “Save my email attachments to a SharePoint document library” like below.
Then Select the template.
Then make sure to connect to SharePoint, Office 365 outlook and Office 365 Users.
Then click on Continue. Once you click on the Continue button it will create the flow and the flow looks like below:
Now let us understand how this flow works.
First, we need to select the folder, for this click on, on new email with attachment flow action. Their select Inbox, you can also select other folders of your email like Archive, Conversion History, Deleted Items, Draft, Junk Email, etc like below:
Then you can see Microsoft flow added a few other flow actions like Initialize variable and Condition. The first time the value of the IsFromFilterApplied variable is False, that means there is no from address filter is there.
So it will save all the attachments coming from any email address.
Later, we will make it to true and we will see how it is working for a particular From address.
Since the variable condition is set to No, it will go to the No condition. And this will save attachments to the SharePoint document library.
Here, select your SharePoint Online site and the SharePoint document library where you want to save the email attachments.
Note: Make sure to provide the site address and SharePoint document library name in both Yes and No condition.
And if for any reason, it is not able to create the file or save the attachment to the SharePoint library, then it will trigger an email to the user. In those case the status error code will be 403.
Now, we can test the flow. So save the flow and then when you receive an email with attachment(s) from others you can see the attachment(s) got saved to the SharePoint library.
Once you received an email, the flow will trigger and you can see the file will be created in the SharePoint document library.
Save my email attachments to a SharePoint document library automatically from a particular email address
Now, we will see how to save my email attachments to a SharePoint document library automatically from a particular email address.
We need to edit the flow and for this, we need to change in two places in the flow.
First, we need to set IsFromFilterApplied variable value to true.
Edit the flow and click on Initialize variable workflow action, go to Expression, type true, and click on OK.
Now, the value of the variable will be true like below:
Now, we need to set the From email address in the Check From email address flow action. That will available in the If Yes part.
There provide the email address. In this case, you can see below I have provided the email address.
Microsoft Flow email address case sensitive
I want to add a note here, the Microsoft flow email address is case sensitive. So the From email address you are providing here will be case sensitive.
So if you are not sure, what exactly your from Email address is, you can add a variable and try to send the From email address value like below:
Microsoft flow email address case sensitive.
Here, I have just created a string variable and assign the From value to it and then I am sending the value in my email. This is just a way to get the exact email id.
Now, our flow is ready for testing. Now, if an email is coming from the particular email address, then the attachment will be saved to the document library.
If the email is coming from other email addresses then it will not save.
Here I have sent an email from Bhawana email address like below:
The flow triggers and you can see the attachment got saved in the SharePoint Online document library.
This is how we can save my email attachments to a SharePoint document library automatically.
What will happen if the attachment already exists in the SharePoint document library?
Lot of time you will see the attachment or file with the same name already exists in the SharePoint document library, what the flow will do that time?
It will override the file, basically it will replace the new file with the old file.
If email contains multiple attachments?
If the email contains multiple email attachments, then it will save all the files in the SharePoint document library.
In this tutorial, we learned how to save my email attachments to a sharepoint document library using Power Automate or Microsoft flow.
Also, we explore how to configure the flow, so that it will save my email attachments to a SharePoint document library only if it is coming from a particular email address.
In this tutorial, we learned Power Automate save email attachments to SharePoint with a few examples.
- How to save email attachment to sharepoint document library on Power Automate?
- How to save multiple email attachments to sharepoint document library on Power Automate?
- How to save excel email attachment to sharepoint document library on Power Automate?
- How to save email attachment to sharepoint with different name on Microsoft flow?
- How to create new item and save email attachment to sharepoint list on Microsoft Flow?
You may like the following Power Automate tutorials:
- SharePoint auto generate column value using Power Automate or Flow
- Microsoft flow Send an email showing wrong time for SharePoint list column
- Microsoft flow change true to yes
- How to get manager email or name in Microsoft Flow
- Microsoft Flow Example: Product Notification Approval Flow
I am Bijay a Microsoft MVP (8 times – My MVP Profile) in SharePoint and have more than 15 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com