Skip to main content

Notifications

Adding multiple attachments to the approval email with Power Automate

The approvals action has been very helpful for us, it has helped in designed many scenario's and has made tasks easier.

 

Recently there has been addition to the approval action card where in we can add attachments to the approvals. When we try to add a single attachment this works fine but when we have multiple attachments this is running into an FOR EACH loop causing the flow to re-run the approval action card multiple times.

 

Because of this user may receive multiple approval requests to over come this behavior, I have found a way where in we can add multiple attachments to the approval mail and this will not run into a FOR EACH loop. The steps for this are almost the same how we try to add multiple attachments to an email.

 

Here with I have created a flow with below steps.

 

The flow is that when an item is created in share point list with multiple attachments, add those attachments and send an approval including them.

 

Let start by adding a trigger – “When an item is created” and selecting the correct SharePoint Site and List.

Please ensure that you already have SP List created that allows storing multiple attachments on the items in it.

Item creation.JPG

 

 

 

 

 

 

After adding the trigger, we need to fetch all the attachments added to the newly created list item. We should, hence, add the “Get attachments” action. The Site name and List name remain the same from the previous step. We want to then pipe the output “ID” from the trigger, to the input ‘ID’ field.

Attachments action.JPG

 

 

 

 

 

 

 

Now, that we have a track on all the attachments – we must store these in a single array. Let’s start by initializing an array for the same

initialize array.JPG

 

 

 

 

 

 

Now as we have initialized the array, in the next step we will fetch and store the attachments contents in the array. This is the main step that leads us to adding multiple attachments, so be careful to follow the instructions.

apply to each step.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • Start by adding a “apply to each loop”, then chose the “body” output from the “Get Attachments”

  • Next add “Get attachment content” action inside the loop. The SP site name and list name don’t change.

    • For the ID field – select ID output from the “When an item is created” trigger

    • For the file identifier field – Select the Id output from the “Get Attachments” action.

  • Next, we want to start adding to the array we just initialized. Set it up as shown below

append to array step.JPG

 

 

 

 

 

 

 

For reference I am showing the content that I have passed in the Append to array variable step again below.

{

"Name": Display name for the new file being created,

"Content":"Content of the file"

}

The content has to be enclosed in doublequotes("). 

 

Our array, contains the attachment item with two properties – Name and Content. We are assigning the DisplayName, retrieved from “Get Attachments” action to the Name property and the Attachment Content, retrieved from “Get Attachment Contents” action to the Content property.

 

Now for the final step we need to send the approval email with the attachments array we just constructed.

 

This step is pretty simple, add an action to send the approval email and pipe in the attachmentArray output to the attachments input field.

 

approval action.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

That's all once you have successfully created and saved your flow, be sure to test it by exercising the trigger you should see an email as shown below in your inbox with multiple attachments send on single approval request.

 

Final email.JPG

 

 

Note: If you getting any error related to attachment content please try converting the content into base64 format using the base64() function in flow.

Comments

*This post is locked for comments

  • MD35981 Profile Picture MD35981
    Posted at
    Adding multiple attachments to the approval email with Power Automate

    MD35981_1-1719504359046.png

     

    1. You only need first and third actions (2nd is for different purpose).

     

    MD35981_2-1719504408060.png

     

    MD35981_3-1719504477578.png

     

    MD35981_4-1719504504491.png

     

    • In Attachments Item -> "content:" enter expression - 
      base64ToBinary(item()?['contentBytes'])
       
      This will help download and open attachments correctly.
      Hope this helps!

     

  • suns3t Profile Picture suns3t 7
    Posted at
    Adding multiple attachments to the approval email with Power Automate

    I was finally able to attach multiple files to approval flow by use body('Get_file_content_using_path') for "Content" at the Append to array variable action (no need to have double quotes here - see my screenshot below) . I used Get file content using path because my attachment file was saved in a OneDriver folder. 

     

    Hope it help.

     

    suns3t_0-1638626544930.png

     

  • MP_Squared Profile Picture MP_Squared 26
    Posted at
    Adding multiple attachments to the approval email with Power Automate

    Great Article @Krishna92!

     

    Would I need to use a condition to evaluate if there is or isn't any attachments to add to the approval? Or does the append array variable  take that into to account in the approval process. Thanks

  • Grace_KAMGOUA Profile Picture Grace_KAMGOUA 28
    Posted at
    Adding multiple attachments to the approval email with Power Automate

    Hi @ExcelNerd !

     

    I suggest you put the send an email step out of the apply to each loop. This way, it collects all the attachments and add it to the array before sending the email.

     

     

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • Grace_KAMGOUA Profile Picture Grace_KAMGOUA 28
    Posted at
    Adding multiple attachments to the approval email with Power Automate

    Hi @ExcelNerd !

     

    I suggest you put the send an email step out of the apply to each loop. This way, it collect all the attachments before send the email.

  • ExcelNerd Profile Picture ExcelNerd
    Posted at
    Adding multiple attachments to the approval email with Power Automate

    Hello all,

     

    I created a flow that checks the current date against a column in a SharePoint list, and when they match it sends an email containing all the attachments associated with that list item.  This tested well; so far, except the flow is sending two separate email instead of just one.  The first email contains only the first attachment, while the second contains both attachments which is the intended result.

     

    Any ideas why two email are being sent, and how to reduce to just one email with both attachments (the second email shown on the right)? 

     

    ExcelNerd_11-1598984962554.png

     

     

    Here is the flow:

    ExcelNerd_1-1598984435062.png

     

    ExcelNerd_2-1598984468766.png

     

    ExcelNerd_3-1598984508847.png

     

    ExcelNerd_10-1598984854689.png

     

    ExcelNerd_9-1598984799235.png

     

    ExcelNerd_6-1598984580737.png

     

    ExcelNerd_8-1598984680092.png

     

    I would appreciate any insight into how to correct this!

     

    Thanks in advance,

    Dan

  • Grace_KAMGOUA Profile Picture Grace_KAMGOUA 28
    Posted at
    Adding multiple attachments to the approval email with Power Automate

    Hi @Krishna92  ! Hi Everyone !

     

    I have created a flow that collects attachments from a list item on sharepoint online based on a choice column value and send it in approval mail for approbation. 

     

    I have done exactly what you've explained and approval mail works fine, the attachments are added to the mail but when trying to download them the files seems to be corrupted.

     

    What could be the problem? 

     

    Approb_WF1.pngApprob_WF2png.pngApprob_WF3.pngApprob_WF4.pngApprob_WF5.pngApprob_WF6.pngApprob_WF7.png

  • Adding multiple attachments to the approval email with Power Automate

    Hello @VswaldB ,

    I have been following along this week, as I need to copy attachments from a list over to an email.

    I was able to get the attachment to display, along with its size, but when I open it (a PDF), nothing shows up.  It's like its empty.  

    Here is my append step:

     
     

    When I review the flow that ran successfully, I see that the content line is different.

    The Get attachment content Output shows this:

    Get_attachment_content.jpg

     

    and the Append to array variable Input is this:

    Append_array_variable.jpg

     

    That array is attached to the Send email (v2) and shows the same value.

    The "Name" displays correctly as an attachment, however opening it shows a blank page.

    Any thoughts on getting the content to actually transfer and display?

     

    Thanks,

    Dave

     

     

     

     

  • VswaldB Profile Picture VswaldB 24
    Posted at
    Adding multiple attachments to the approval email with Power Automate

    @Anonymous 

     

    So from my own experience, I did not use the base64() function at all... and it worked for me and once it's working I can add it to every "Send Email" function. maybe you can try if it also works for you

  • Adding multiple attachments to the approval email with Power Automate

    Hello @VswaldB ,

     

    I added it to the " Append to array variable"step and it worked. adding it to the attachment did not work for me...

     

    Anyway, I also would like to add the same attachments to a "send an email (V2)" action. I tried to just add it like I did in the approval step but it didn't work. Do I need to do anything different for it to work?