Do you want to attach a single file or multiple files to an email you send from Power Automate? Then this Power Automate tutorial is for you. I will explain how to send an email with attachments in Power Automate.
Here we will cover two examples: First, we will see how to send an email with single or multiple attachments from a SharePoint Online list in a flow in Power Automate.
Secondly, we will learn how to send an email with an attachment or with multiple attachments from OneDrive in Power Automate.
Send an Email with Attachments from SharePoint list using Power Automate
Using Microsoft Flow, let us see how to send an email with single and multiple attachments from a SharePoint list.
The Power Automate flow that we will create now supports sending an email with a single attachment and multiple attachments from the SharePoint list.
Scenario:
The flow triggers automatically when a new item is created with an attachment in a SharePoint list. Later, using the Get Attachments action, it retrieves the attachments for the particular list item, and finally, by using Send an email (v2) action, it sends an email to the corresponding user in Powe Automate flow.
To achieve this, follow the below steps:
Step-1:
Create a SharePoint Online List. Here I have created a SharePoint List called Employee Documents consisting of,
- EmployeeID – Default Title column
- EmployeeName – Person or Group column
- EmployeeDesignation – Single Line of Text
- Attachments – default attachment column
Step-2:
- Our SharePoint list is created, so now we will create a flow to send an email with attachments from the SharePoint list.
- Log in to Power Automate flow using the credentials, and select +Create -> Automate cloud flow.
- Enter the flow name, choose the trigger when an item is created, and click the create option.
Step-3:
Expand the trigger action and configure the SharePoint site address and List Name. I have selected my site address and SharePoint list called Employee Documents.
Step-4:
- Select the +new step and select Initialize variable action, Enter the variable name, and choose the variable type as Array to save the attachments. Leave the Value field blank.
- Later we will use the initialized variable in our flow.
Step-5:
- Add a Delay action from action triggers and set the count as 15 and the unit as seconds. Here we are delaying action to retrieve all the attachments from the SharePoint list without fail.
- Because sometimes it takes time to upload, we are setting a delay action to retrieve all the attachments from the SharePoint list item without missing any attachments.
Step-6:
Select the Get Attachments action to get all the attachments from the SharePoint list. Configure the SharePoint site address and list name. Add the ID value from the dynamic content value.
Step-7:
- Select the next step and then choose Get attachment content to read all the contents. Configure the SharePoint site address, list name, and ID.
- In the File identifier, add the id of getting attachments from the dynamic content, it will automatically add Apply to each control to get the attachment content for the SharePoint list item.
Click on the next step, select Append to array variable action, and select the initialized variable called Attachments (ie: Step-4:) from the dropdown. In the value field, pass the below JSON code.
{
"Name":@{item()?['DisplayName']},
"ContentBytes":@{body('Get_attachment_content')}
}
Step-8:
- Select Send an Email V2 outlook action from action triggers; enter the recipient’s email in the To field.
- Provide the Subject and Body of the mail. Expand Show Advanced options.
- In the attachment section, click on the icon to switch to the entire array of attachments.
- Select the initialized Variable name from the dynamic content value with all the attachments.
Step-9:
Save and Run the flow, by selecting the run flow option. The flow will trigger only when we create a new item in the SharePoint list.
Case-1: Send an email with an attachment from SharePoint list using Power Automate
Here in the SharePoint list, I have created a list item with a single attachment as highlighted below:
Once our flow runs successfully, like below:
Now, The mentioned user will get an email with a single attachment from the SharePoint list as shown below:
Case-2: Send an email with multiple attachments from SharePoint list using Power Automate
Now I have created a list item with 3 attachments as highlighted below:
Once our flow runs successfully, The mentioned user will get an email with all the 3 attachments from the SharePoint list, as shown below:
This is how to send an email with a single attachment and Multiple attachments from a SharePoint list using a Flow.
Send an email with an attachment from OneDrive in Power Automate
Here we will see how to send an email with a single attachment and Multiple attachments from OneDrive using a flow in Power Automate.
Example-1: Send an email with an attachment from OneDrive using Power Automate
Let us see how to send an email with a single attachment from OneDrive using Flow.
Scenario:
The flow triggers automatically when a new file is uploaded to the Documents in OneDrive. Later, using the Get File Content, it retrieves the attachment, and finally, by using Send an email (v2) action, it sends an email to the mentioned user in Powe Automate flow.
To achieve this, Follow the below steps:
Step-1:
Here I have created one New Folder in OneDrive called Employee Documents as shown below:
Step-2:
- Log in to Power Automate flow using the credentials, and select +Create -> Automate cloud flow.
- Enter the flow name, choose the trigger when a file is created, and click the create option.
Step-3:
Expand the trigger action and select the Folder from the Show Picker. Here I have selected the Employee Documents.
Step-4:
Add Get File content action to get attachment content. In the File field, pass the dynamic content value of the File Identifier.
Step-5:
- Select Send an Email V2 outlook action from action triggers; enter the recipient’s email in the To field.
- Provide the Subject and Body of the mail. Expand Show Advanced options.
- In the Attachments Name, Pass the dynamic content value of the File Name. In the Attachment Content, pass the dynamic File content value.
Step-6:
Save and run the flow by selecting the Run flow option. The flow will only trigger when a file is created in OneDrive. I have uploaded a file to the Employee Documents folder presented in OneDrive.
Now our flow runs successfully like below:
The mentioned user will get an email with a single attachment from OneDrive as shown below:
This is how to send an email with a single attachment from OneDrive using Flow.
Example-2: Send email with multiple attachments from OneDrive using Power Automate
Here we will see how to send an email with Multiple attachments from OneDrive using Flow.
Scenario:
The flow triggers manually; initially, the List all the Files action gets all the files presented in the OneDrive folder. Later, using the Get File Content action, it retrieves the content of all attachments. And finally, by using Send an email (v2) action, it sends an email to the corresponding user in Powe Automate flow.
To achieve this, Follow the below steps:
Step-1:
Select the OneDrive folder to send the user all the files presented in the folder as email attachments. Here I am going to use the Employee Documents folder has 3 different attachments as highlighted below:
Step-2:
- Log in to Power Automate flow using the credentials to create a flow, and select +Create -> Instant cloud flow.
- Enter the flow name, choose the trigger as manually trigger a flow, and click the create option.
Step-3:
- Select the +new step and select initialize variable action; enter the variable name and choose the variable type as Array to save the attachments. Leave the Value field blank.
- Later we will use the initialized variable in our flow.
Step-4:
Add a new step and choose List files in folder action. Select the Folder from the Show Picker. Here I have selected the Employee Documents.
Step-5:
- Choose the Get file content action, to read all the attachment’s content based on the ID. Pass the dynamic content Id value.
- It will automatically add Apply to each control to get the attachment content from OneDrive.
Click on the next step, select Append to array variable action, and select the initialized variable called Attachments (ie: Step-3:) from the dropdown. In the value field, pass the below JSON code.
{
"Name":@{items('Apply_to_each')?['DisplayName']} ,
"ContentBytes": @{body('Get_file_content')}
}
Step-6:
- Select Send an Email V2 outlook action from action triggers; enter the recipient’s email in the To field.
- Provide the Subject and Body of the mail. Expand Show Advanced options.
- In the attachment field, click on the icon to switch to the entire array of attachments.
- Select the initialized Variable name from the dynamic content value with all the attachments.
Step-7:
Save and Run the flow by selecting the run flow option. Once the flow runs successfully, like below:
It gets all the 3 files presented in the Employee Documents folder in OneDrive and sends an email with multiple attachments to the mentioned user.
This is how to send an email with multiple attachments from OneDrive using Flow. This is how to send an email with single and multiple attachments from OneDrive using Power Automate.
Conclusion
We can easily send email attachments while sending using Email in Power Automate. I have explained how to send emails with attachments in Power Automate from SharePoint. And also, I have shown you how to send an email with attachments from OneDrive using Power Automate.
You may also like:
- How to count items in an array using Power Automate?
- Convert XML to string in Power Automate
- How to send email from excel using Power automate?
- Send an email with options in Power Automate
- Create a Word Document from HTML using Power Automate
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 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