SharePoint and Power Apps are like match made in heaven. More often than not I find Power Apps implementations on top of SharePoint data.
And if you are working with SharePoint data, you must have worked with SharePoint ListItem.
And with that, here is the requirement. Whenever an item is added to SharePoint list item, I should send an email to a specific group of people with all the attachments for that list item. Quite a simple requirement, isn’t it?
Below is the screenshot of the flow.
We start with the obvious trigger – “When a new item is created“
The most important thing here is how do we send multiple attachments in the list item in a single email. For that observe the actions circled in green.
I declared an array variable. Then I use the Get Attachments action of SharePoint to get all the attachments for the list item created. Then I loop through each attachment and use the action Get attachment content to get the content of each attachment.
Now comes the most important step. Adding the content to the array variable. And for that I use the ‘Append to an array variable‘ action.
What is important here is the value. It’s a JSON object with two properties – Name and ContentBytes
{
"Name": "items('Apply_to_each')?['DisplayName']",
"ContentBytes": "body('Get_attachment_content')['$content']"
}
The trick here is not to use the “Attachment Content” output property highlighted in the screen shot below.
Rather for ContentBytes we just need to use the bytes from the body of action. And that you get using the below expression.
body('Get_attachment_content')['$content']
Well, that’s it. The final step is to send the email and the attachments property, you need to set to the array variable.
And you are all set.
Hope this helped!
You will also like the below posts.
Debajit Dutta
Business Solutions MVP
Discover more from Debajit's Power Apps & Dynamics 365 Blog
Subscribe to get the latest posts sent to your email.