Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
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

 

 

  • NiloferA Profile Picture
    on at
    Re: Apply to Each with case statement on email attachments

    Well, it happens sometimes. Glad it worked!

  • jhardwick Profile Picture
    28 on at
    Re: Apply to Each with case statement on email attachments

    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.

  • Verified answer
    NiloferA Profile Picture
    on at
    Re: Apply to Each with case statement on email attachments

    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!

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1