📝Best Practices for Formatting File Attachment Arrays in Approvals, Outlook Emails, OneDrive, and SharePoint

When working on collaborative projects or sending emails, file attachments are a crucial part of sharing information. However, inconsistencies in the formatting of file attachment arrays across different Power Automate actions can lead to confusion and errors. In this blog post, I explore best practices for formatting file attachment arrays in common Power Automate actions, such as approvals, Outlook emails, OneDrive, and SharePoint.

The following format of file attachments arrays for Approvals and Outlook Emails, OneDrive and SharePoint seem to work well in Power Automate:

The format of the attachments array for Outlook Emails, OneDrive and SharePoint.
The format of the attachments array for Approvals attachments, Outlook email attachments, OneDrive and SharePoint files.

Corrupt attachments? Files won’t open?

If you find that in some instances the above does not work, i.e., the file attachment won’t open, I have included an alternative format for the attachments array.

Files won't open
Outlook attachment won’t open

File Attachments for Approvals #2

In APPROVALS 2 below I specify the content-type so that app knows what the media/file type of a resource is.

{
  "content": {
    "$content-type": @{items('Apply_to_each')?['contentType']},
    "$content": @{items('Apply_to_each')?['contentBytes']}
  },
  "name": @{items('Apply_to_each')?['name']}
}

For a working example see the section Corrupt attachments? Attachments won’t open? in How to send Microsoft Forms file uploads to an Approval workflow using Power Automate

File Attachments for Outlook Email Attachments, OneDrive and SharePoint Files #2

In the image below I specify the content-type so that app knows what the media/file type of a resource is.

an alternative for Outlook Attachments
{
  "name": "@{items('Apply_to_each')?['DisplayName']}",
  "contentBytes": {
    "$content-type": "@{body('Apply_to_each')?['$content-type']}",
    "$content": "@{body('Apply_to_each')?['$content']}"
  }
}

The example below shows the attachment array added to an approval action and an Outlook email:

File attachment arrays added to an Approval action and an Outlook email.
File attachment arrays added to an Approval action and an Outlook email.

So, why do different array format work for some people but generate corrupt attachments for others?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Website Built with WordPress.com.

Up ↑

%d bloggers like this: