cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MN003
Post Patron
Post Patron

Attachment Array Assistance

Hello,

 

I'm trying to create a second attachment array to be able to add attachments to emails. I already have one in my flow for approvals that works perfectly. I tried to create a second array but got an error and have been unsuccessful. Are there recommended steps I can try? I'm unsure if I need to create a new Apply to Each and where it should go or if I can add another append to variable within the same one (didn't work previously). I appreciate any help/guidance. Thank You.

 

Attachment Array.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User
Super User

Try this:

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

From this post on my blog:

https://www.tachytelic.net/2020/09/power-automate-add-multiple-attachments-approval-email/

(Covers both approvals and email attachments arrays) 

View solution in original post

13 REPLIES 13
Paulie78
Super User
Super User

Try this:

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

From this post on my blog:

https://www.tachytelic.net/2020/09/power-automate-add-multiple-attachments-approval-email/

(Covers both approvals and email attachments arrays) 

Thanks Paulie, I'm experiencing an error in the email now. It's saying that the input parameters for "To", "Subject", and "Body" are missing. I'm not sure why it's saying that because they're all filled in and worked just fine before. Any thoughts?

 

MN003_0-1613747324150.png

 

Paulie78
Super User
Super User

No idea, click on the "Show Raw Outputs" and the inputs section and post them here. For testing, just hard code values in and see if it works.

Sure and will try to play around with it.

 

MN003_0-1613748083526.png

 

Paulie78
Super User
Super User

You didn't capture quite enough of the message for me to see the actual error, just copy and paste the text.

Removed error message.

Paulie78
Super User
Super User

Well, it is quite clear it thinks you have not provided those values, and I guess you have. So I would check the values of those things in a compose step before you hit that part, to make sure, that they do actually have some content.

Yeah it's really weird. Ok maybe I will try to add a compose and see if that helps.

 

MN003_0-1613748661521.png

 

Success. Paulie I just modified the original code you provided to: 

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

Paulie78
Super User
Super User

Well done.

Thanks again Paulie, you rock! I actually had the link you provided earlier already favorited from a few days ago so you helped bring me to finish line and today I crossed it. 🙂

@Paulie78 Thanks for your post and solution, but quite annoying and bizarre. I have many flows where my multi -attachment array sent by email works perfectly with:

 

 

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

 

 

but yesterday as I was creating a new flow with the same steps, the attachments were failing to open from Outlook, I kept getting an error similar to when an attachment or file is corrupt .

DBJ_0-1618511921596.png

 

No matter what kind of attachment (docs, images, pdfs, etc.). But I just tried it with what you suggested, i.e. adding: 

 

"$content-type": "@{body('Get_attachment_content')['$content-type']}",

 

and now no more issue opening the attachments. Somekind of API requirement change implemented?  Drove me crazy 😤 !

Paulie78
Super User
Super User

Dont know what changed, but well done for figuring it out.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (5,960)