Power Automate

Sending Multiple Email Attachments from Power Automate

August 27, 2021

There are occasions within Power Automate where we need to facilitate the sending of multiple email attachments, however done incorrectly you will see a number of errors. In this blog we look at how we can easily send multiple email attachments.

Whilst working on a project today my team and I were trying to take attachments, from a list item in SharePoint, and then send them to a recipient as part of an email. We needed to cater for the possibility of several attachments being sent on a single email, and so we set about doing this.

We actually saw some strange messages when we were trying to send our attachments including:
"Status code 400 and message": "No input parameters provided. Please provide required input parameters 'To', 'Subject' and 'Body'.\r\nclientRequestId:"

Alternatively I also saw the error where it said that it was unable to read the attachment content, which considering I was using the content dynamic content, I was really surprised.



There is a really simple solution to this, issue, but before I go into the solution I'm going to refer you to the blog post that we started with. This is a really good blog post by Sunay Vaishnav which was  "Advanced | Flow of the Week: Send multiple attachments on a single email".

There were a few people in the comments who had reported the exact same issue, and there were some solutions offered. In this I would like to suggest a simpler answer, and an explanation as to why I believe the error occurs.

The Issue

The issue purely comes down to the format in which the attachment content gets fed into the REST call being made to Outlook. Behind the scenes, all actions are web services calls which are made up of a URL, headers, and a body. The body and headers are both JSON, so if something goes in there which does not conform to the required schema, or even to valid JSON, then the action will fail.

Failure is exactly what we have seen with this action, with the direct input from the attachment content dynamic content resulting in poorly formed JSON. Effectively it's destroying the JSON so that not even the subject, to or anything else are recognisable.

The Resolution

The resolution is actually very simple, all it requires is a small expression. The content from the attachment is retrieved as a byte array, which won't be recognised as valid. What it actually wants is a base64 string. It is really easy to do that conversion as there is an expression named "base64", therefore we just need to wrap the attachment output in this expression.

To do this, append to your array variable in exactly the same way as was described by Sunnay, however when you put in your ContentBytes content, switch to the expression editor, and enter:

base64(<your attachment content dynamic content>) e.g. base64(body('Get_attachment_content'))


This will convert your content from byte to base64 so that the Outlook connector can then take the input and process it in the correct way. This will then cure your error and send the email attachments as you would expect.

If you need any further help on this, please feel free to ask.

- Matt Weston

Join the 365 community

Sign up for content updates
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Related blogs

Articles you might like

Power Automate
Sending Multiple Email Attachments from Power Automate

There are occasions within Power Automate where we need to facilitate the sending of multiple email attachments, however done incorrectly you will see a number of errors. In this blog we look at how we can easily send multiple email attachments.

Learn More
Power Automate
Setting and Updating SharePoint Hyperlink fields in Flow and Logic Apps

The hyperlink field in SharePoint is extremely simple to set through the SharePoint UI, but when it comes to Power Automate it's a completely different story. We have to be able to set both the hyperlink and the description, but the standard actions only allow you to set the hyperlink. This is how we get the result we desire!

Learn More
Power Automate
Moving a Microsoft Forms attachment from OneDrive to SharePoint

When we first create a form using Microsoft Forms, it is classed as personal. This means that it is associated with my account, and stores any attachments in my OneDrive. In this scenario, we may not wish to share the actual form itself, but we want to move the file automatically to SharePoint so that we can work with it more effectively.

Learn More