• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Tachytelic.net

  • Sco Openserver
    • Sco Unix Support
    • SCO Openserver Installation ISOs
    • SCO Openserver Binaries
    • Add a Hard Drive to an Openserver 5 Virtual Machine
    • Install SCO Vision SQL-Retriever ODBC Driver on Windows 10
    • License Expired on Virtual SCO Openserver Installation
    • How to reset the root password on SCO Openserver 5
  • Scripting
    • PowerShell
      • Add leading zeros
      • Check if a File Exists
      • Grep with Powershell
      • Create Environment Variables
      • Test for open Ports
      • Append to a Text File
    • VBScript
      • Check if a File Exists
      • lpad and rpad functions
      • Windows Update E-Mail Notification
  • Office 365
    • Connect to Office 365 with PowerShell
    • Add or remove an email alias using Powershell
    • Change Primary email address of Active Directory user
    • How to hide an AD user from the Global Address List
    • How to hide mail contacts from the Global Address List
    • Change the primary email address for an account with PowerShell
    • Change Primary email address of an AD User
    • Grant a single user access to access to all calendars
    • Forward email to an external address using Powershell
    • Convert shared mailbox to user mailbox with Powershell
  • Get in Touch
  • About Me
    • Privacy Policy

Add multiple attachments to an approval email with Power Automate

September 25, 2020 by Paulie 13 Comments

Adding multiple attachments to an approval flow in Power Automate is a common requirement. The method is slightly different between the Create an Approval action and the Send an email(V2) action. I will demonstrate both methods in one flow, using a SharePoint list as an example:

First, create the trigger action and initialize two array variables. There are separate arrays for the email action and the approval action:

Image showing first steps of a flow in Power Automate.

Next, use the Get attachments action and provide the same site and list address as before. Use the ID from the trigger action.

Image of Get attachment action in Microsoft Power Automate to pull attachments from a SharePoint list.

Now use the Get attachment Content action and again supply the site and list name. For the ID field use the ID from When an Item is created. Finally, for the File identifier, use the Id from the Get attachments step:

Image of "Get attachment content" action in Power Automate.

This action will now change to be inside an Apply to Each action.

Fill the arrays with the attachment content

The next step is to populate the arrays with the contents of the attachments. Use the append to Append to array variable action. Here is how to build the approvals attachment array.

Image of Power Automate array containing multiple attachments for use in an approval flow.

The code for the approval attachment array is:

{
  "content": {
    "$content-type": "@{body('Get_attachment_content')['$content-type']}",
    "$content": "@{body('Get_attachment_content')['$content']}"
  },
  "Name": "@{items('Build_Attachment_array')?['DisplayName']}"
}

Now populate the email attachment array:

Image of Power Automate array containing multiple email attachments.

The code for the email attachment array is:

{
  "ContentBytes": {
    "$content-type": "@{body('Get_attachment_content')['$content-type']}",
    "$content": "@{body('Get_attachment_content')['$content']}"
  },
  "Name": "@{items('Build_attachment_array')?['DisplayName']}"
}

Notice how the required code is slightly different on line two.

Use the arrays as the attachment content

Now you can simply insert these arrays into the “Create an Approval” or “Send an email(V2)” actions.

Image of an approval flow having multiple attachments added

Here is an image of my entire flow that shows how to send multiple attachments in approvals in a flow from a SharePoint list (click to expand).

Image of a Power Automate Flow showing how to add multiple attachments to an approval

Corrupt attachments

Slightly different solutions to this problem have been discussed in the Power Automate forums but for me, they resulted in corrupted attachments. Adding the correct content type for each of the file attachments fixes the corruption.

I also found that sometimes the file size would increase dramatically.

I’d like to understand why the different array format works for some people and generates corrupt attachments for others.

Related

Filed Under: Office 365, Power Platform Tagged With: Approvals, Power Automate

Reader Interactions

Comments

  1. Jenna R. says

    October 13, 2020 at 8:35 pm

    I’ve been struggling for weeks to get SP list item attachments to successfully attach to a power automate approvals flow email notification. I kept creeping closer and closer via other blog posts and forum threads, but still ran into the corrupted file issue. This post was the final piece of the puzzle by adding the content-type component to the appended array. THANK YOU — my entire household celebrated with me (I think my vocal frustrations had been bleeding into others’ work and learn from home experiences). Thanks again!

  2. Paulie says

    October 13, 2020 at 9:37 pm

    Thanks for your comment – appreciated as I also spent a long time figuring this out (even though the solution is quite simple) and got very frustrated to the point of almost giving up. Other solutions I’ve seen were on the right scent but didn’t provide a working solution.

  3. Harry Teguh says

    October 28, 2020 at 11:56 am

    Wow! Your solution works great! I’ve been tearing up my hair for days just to solve this issue. Thank you!

  4. Paulie says

    October 28, 2020 at 12:05 pm

    Welcome to the hair loss club! I experienced the same and exactly the reason I wrote it up!

  5. Silvia says

    November 5, 2020 at 9:31 am

    Thank you so much! I was going crazy with this!!

  6. Gillian Eastwood says

    December 4, 2020 at 6:05 am

    I followed your instructions to a tee….. and I am getting “Flow save failed with code ‘InvalidTemplate’ and message ‘The template validation failed: ‘The reprtition actions(s) ‘Build_attachment_array referenced by ‘inputs’ in action ‘Append to array variable’ are not defined in the template”.

    I have literally spend probably 40 hours trying to figure this out….so any help would be GREALT appreciated 🙂

  7. Dan says

    December 9, 2020 at 6:59 pm

    YEAH!!! Thanks for the detailed guide.

  8. Premalatha says

    December 18, 2020 at 11:10 am

    @Gillian Eastwood Im getting the same error. Got any resolution?

  9. Premalatha says

    December 20, 2020 at 8:32 am

    Got resolved finally after spending around 40 hours in dealing with corrupted attachments—

    Now. Append Array code looks like :

    {
    “inputs”: {
    “name”: “AttachmentArray”,
    “value”: {
    “name”: “@items(‘Apply_to_each’)?[‘DisplayName’]”,
    “content”: “@body(‘Get_attachment_content’)?[‘body’]”
    }
    }
    }

  10. Chris says

    December 22, 2020 at 6:42 pm

    I followed this exactly for approvals and the attachment arrives with the approval but it is corrupt and can’t be opened. Same as every other method.

  11. Paulie says

    December 22, 2020 at 6:57 pm

    Chris, would love to do a quick remote session with you to have a look at why it’s not working for you. Let me know if you’re up for it

  12. Chris says

    December 22, 2020 at 8:17 pm

    I’m the same “Chris” from December 22nd – Not sure what I screwed up the first time around but I can confirm that this does work for approvals (I spent almost 8 hours trying to figure this out before finding this blog). What I think I was doing wrong, when I thought this didn’t work, was saving and “Testing” it using old Flow runs over and over and each would fail. When I tried adding a new item to my SharePoint test list, it worked.

  13. Paulie says

    December 22, 2020 at 8:52 pm

    Glad you got it sorted and it worked for you. One lady that arrived here had literally spent 20 hours!

Leave a Reply Cancel reply

Primary Sidebar

Power Automate Support Image
Link to my LinkedIn Profile
Go to mobile version