Power Automate — Send email with attachments when adding new item in SharePoint.

Wu Gang
4 min readAug 5, 2020

--

Recently I make a small configuration in Office 365 — Power Automation to send email with attachments when adding new item in sharepoint. Hope it can help you if you plan to do the same thing.

Trigger: new item created from SharePoint list — Claim List.

Action: send email to particular user with item information and attachments.

Overview steps:

Let’s get it done step by step.

First come to Power Automate and create new from My Flow:

Choose trigger ‘When an item is created’ for SharePoint

Step 1: setup trigger, choose the SharePoint and the list. This is the trigger of the flow, when item is created in the sharepoint list, the flow will start.

Step 2: Insert new step and get Attachment (SharePoint)

Next, choose ID from dynamic content into Id field, this will get the Attachments of the into flow context.

Step 3: to support multiple attachments, initial an empty array. name the array variable as ‘attachArray’.

Step 4: To support multiple attachments, put attachments from sharepoint list item to the variable create at last step within a loop.

  1. Add a ‘Apply to each’ control , choose ‘body’ from last step in dynamic content.

2. Click ‘Add an action’, add action ‘Get attachment content’, sharepoint and the list, then put ID into Id field, choose Id (file identifier) to File Identifier field. Here we are reading each attachment from Attachment list.

3. Click ‘Add an action’, add action ‘Append to array variable’

4. Choose name as ‘attachArray’ , Input with the JSON format in value field. like below , and insert dynamic content ‘DisplayName’ as value of key “Name” and ‘Attachment Content’ as value of key “ContentBytes”. This will grab the Attachment list from SharePoint and put it to the array variable

{
“Name”: ,
“ContentBytes”: ,
}

Step 5: send email by adding dynamic contents :

  1. Choose Action ‘Send an email(V2)’

2. Put email body here , insert claim item information by adding from dynamic content.

3. Add attachment variable to email attachment: click button on right, switch to different attachment view, then insert variable attachArray into Attachments fields

Now everything is ready, let’s save and have a test:

Test:

  1. click the test button on right top

2. Add one record in SharePoint list: attach 2 attachments into the list, and save.

3. All steps should be passed

4. Check in mailbox, email has been received with 2 attachments.

Summary

This is a simple flow that sending email when item is created in SharePoint List. The tricky part is to support multiple attachment, we need create an array variable to save the attachment temporarily, and then add to email attachments.

--

--