Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Power Automate Desktop
Answered

Saving attachments and iterating through them to match emails

(0) ShareShare
ReportReport
Posted on by 11
Hi,
 
So I'm struggling with this issue, I am using the Retrieve email messages from Outlook action for All emails with Subject "ApprovalsTest" and save the attachments into a certain folder. So say there are 3 emails with attachments, they all get saved into the folder just from that one action, but now I have no way of iterating through my emails and moving them to an In Progress folder because I can't match the file saved to the email it came from. This is a snippet of a code and I hope it makes sense of what I am trying to do

 
How can I extract and save attachments one by one or rework my code to make this method work please. Any help would be greatly appreciated, thank you :)
Categories:
  • Verified answer
    TM-18062219-0 Profile Picture
    11 on at
    Saving attachments and iterating through them to match emails
    So I figured out the way to do this! So I did as before with Retrieve email messages from Outlook and saving all the attachments to the folder, but then to match each file in the folder, I matched it against the CurrentEmail.Attachment, the screenshot below will make more sense, so now it only pulls the file that is in the CurrentEmail

  • TM-18062219-0 Profile Picture
    11 on at
    Saving attachments and iterating through them to match emails
    Thank you for the response, I presume thats the AI response from ChatGPT or CoPilot as sadly there is no Save Email Attachment action
  • Suggested answer
    Riyaz_riz11 Profile Picture
    2,934 Super User 2025 Season 1 on at
    Saving attachments and iterating through them to match emails
    Hi,
     
    • Retrieve Emails

      • Action: Retrieve email messages from Outlook

        • Filter: Subject = "ApprovalsTest"

        • Retrieve: Only unread or all (your choice)

        • Store output in variable: %RetrievedEmails%


    • For Each Email

      • Action: For Each

      • Value to iterate: %RetrievedEmails%

      • Current Item: %CurrentEmail 

    • If Attachments Exist

      • Action: If

        • Condition: CurrentEmail.Attachments.Count > 0

    • For Each Attachment

      • Action: For Each

        • Value to iterate: %CurrentEmail.Attachments%

        • Current Item: %CurrentAttachment%

    • Save Attachment to Folder

      • Action: Save email attachment

        • Attachment: %CurrentAttachment%

        • Destination folder: "C:\YourFolder\" (adjust as needed)

    • Move Email to In Progress

      • Action: Move email message

        • Email: %CurrentEmail%

        • Destination folder: "In Progress"

          If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
          Regards,
          Riyaz

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May 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 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492