Power Automate Email Attachments

1700
8
08-01-2022 11:31 AM
Hammers211
Regular Contributor

I need some help with a Power Automate flow that attaches files to from survey responses to an email. I followed this guide:

https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-working-with/bc-p/...

And have come up with this flow:

Hammers21_0-1659377778710.png

 

However, when saving I get this error:

Hammers21_0-1659378272872.png

 

If I remove either of the attachments (so there is just one, either just "Photo" or just "File"), it saves and the flow operates properly.

For example:

Hammers21_2-1659378122763.png

or

Hammers21_3-1659378160483.png

 

How can I do both attachments?

Thanks for any help!

0 Kudos
8 Replies
TL2
by
Frequent Contributor

I assume your attachments can be files and photos?  It seems like the flow just treats them all as attachments so you should only need one variable?  Otherwise you could merge the two arrays into one, but as I mentioned, but seems like you would just be recombining them.

0 Kudos
Hammers211
Regular Contributor

@TL2 wrote:

I assume your attachments can be files and photos?


That is correct, they can be files or photos.


@TL2 wrote:

It seems like the flow just treats them all as attachments so you should only need one variable? 

Is there another/better way to set this up, or a way to not treat them as attachments? As I said, I just followed the guide. My understanding is that two variables would be required, one for photos and one for files. If I could have just one variable and store all the files/photos though, that would be great! That would solve the issue I'm having currently I think.


@TL2 wrote:

Otherwise you could merge the two arrays into one, but as I mentioned, but seems like you would just be recombining them.


I tried merging them at one point, but I was unable to get it to work. I would like to learn how to do this though!

 

 

0 Kudos
TL2
by
Frequent Contributor

My point is it appends attachments to the email.  I don't think the variable cares what the attachment extension is (pdf, jpg, doc).  

For my flow if the operators attached a pdf and took a photo, I would assume they would both be attached in the email.

0 Kudos
Hammers211
Regular Contributor

@TL2 wrote:

My point is it appends attachments to the email.  


Please forgive my ignorance, I'm just learning how to use Survey123. What other options are there aside from appending the attachments to the email? Am I not using a suitable method?


@TL2 wrote:

I don't think the variable cares what the attachment extension is (pdf, jpg, doc).  


Meaning that I could use just one variable?

 

Thank you for the help by the way!

 

0 Kudos
TL2
by
Frequent Contributor

Yea, not could, should.  One array variable.

0 Kudos
Hammers211
Regular Contributor

@TL2 wrote:

Yea, not could, should.  One array variable.


So I did try this at one point, but the JSON was the issue I couldn't figure out. I currently have this:

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

How do I add my second variable to this?

0 Kudos
TL2
by
Frequent Contributor

That looks correct.  The array variable will gather as many attachments are included in the survey and append them.

0 Kudos
TL2
by
Frequent Contributor

Also add a condition to check if attachments exist (here I am calling them photos).  If there are no attachments the flow will fail without an condition to send an email without attachments.

TL2_1-1659638642391.png

 

 

0 Kudos