web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Apply to Each with cas...
Power Automate
Answered

Apply to Each with case statement on email attachments

(0) ShareShare
ReportReport
Posted on by 28

I'm using the "When a new email arrives (V3)" and the message I am wanting to process can have multiple attachments.

For each of the attachments, I need to do a series of steps, but those steps depend on the prefix of the attachments file name.

I have an "Apply to Each" based on the "attachments" for the connector and then a switch statement to get the first 3 characters of the attachment's name.

 

Everything to this point seems to be working correctly, but the problem is I'm so many layers nested the automatic options aren't triggering to help me form the correct expression for "file content" when I go to save the attachment to SharePoint using Create FIle instead I'm getting data such as...

 

{"@odata.type":"#microsoft.graph.fileAttachment","id":"AAMkADcwODk3OTBmLTk4Y2EtNDUxOS1iNWU0LTEyNDZmZWM2Mzc0MgBGAAAAAAD6JyfrZzSxS5vGXXDpttXxBwAc0YdqBVrfTLtJMHx5Ll7eAAAAAAEMAADf0RNVqkXSSJv2SkVpwL51AAUcKzqUAAABEgAQALy-j3E-fm9Fnl1c-IhJr_k=","lastModifiedDateTime":"2021-11-30T23:41:27+00:00","name":"Invoice-EA289D30-0030.pdf","contentType":"application/pdf","size":21212,"isInline":false,"contentId":"6F0E6AAF9.....","contentBytes":"JVBERi0xLjQKM""}

 

I'm sure I'm missing the correct syntax to use on File Content to pull the actual content instead of the overall blob.

 

Example of the flow...

Screenshot 2021-11-30 202706.png

 

 

Categories:
  • Verified answer
    NiloferA Profile Picture
    on at

    Hello @jhardwick ,

     

    You need to add "Attachments Content" from the dynamic content under File Content

     

    NiloferA_0-1638340622311.png

     

    Please hit Kudos if you liked the Reply or Mark it as a Solution if it resolved your problem.

    Thanks!

  • jhardwick Profile Picture
    28 on at

    I swear I had tried that 3x and it wasn't working.  Which for the record it still didn't when I replayed a prior execution.. it would export data, but not a valid PDF. 

     

    When I did a clean run it would export the exact same attachment correctly though.

  • NiloferA Profile Picture
    on at

    Well, it happens sometimes. Glad it worked!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 249 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 202

#3
David_MA Profile Picture

David_MA 180 Super User 2026 Season 2

Last 30 days Overall leaderboard