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.
Solved! Go to Solution.
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)
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?
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.
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.
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.
Success. Paulie I just modified the original code you provided to:
{
"ContentBytes": @{body('Get_attachment_content')['$content']},
"Name": @{items('Apply_to_each_3')?['DisplayName']}
}
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 .
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 😤 !
Dont know what changed, but well done for figuring it out.