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 / Downloading attachment...
Power Automate
Answered

Downloading attachments from mails with Power Automate

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello !

 

I'm pretty new to Power Automate. I'm an intern at a company that recently asked me to make Power BI dashboards based on Bitdefender Gravityzone data. The problem is that the only way I can get this data is through scheduled emails, which are sent to me every hour and have a .csv attachment.


So what I would like to do is to get these attachments automatically (so that the table can run without the need of anyone's intervention). After some researches, I find Power Automate.


So I make a little script.

 

Horus33_0-1671198140507.png

 

In details, it :

 • Delete and recreate the local folder, to remove the older versions of the files

 • Copy the attachments of the mails from a specific folder of my mailbox and mark those mails as read

 • Delete all the mails which from that folder

 

When I try it, either with the normal "Run" or the "Run next action", it does not give me the expected result. Finally, from a display point of view on Outlook (on app or on navigator), even when reloading the page, it doesn't show me the mails as read, neither they appear deleted. The results of the run (aka. the files I get in the created folder) also seem inconsistent, but I'm considering the possibility that the display in Outlook isn't quite right and that it's making me analyze the situation wrong.

 

Can you confirm if this script is supposed to work, and if there may be display issues in Outlook ?

 

I also had another question for you. When I have several files in the same folder on Outlook, in which order are they read ? From the most recent to the oldest, or the opposite ? Because if I have several versions of the same file in the folder and it takes the attachments of the oldest first, it causes me a problem for Power BI, since the updated files are the most recent.

 

And in case it defaults to taking the oldest first, is there any way to reverse the selection order ?

 

Thank you for reading !

  • Verified answer
    VJR Profile Picture
    7,635 on at

    Hi @Anonymous 

     

    Since the RetrievedEmails is a datatable you might want to loop through it and delete the items using the CurrentItem in that loop.

    Something like this.

    VJR_0-1671244475733.png

    Regarding your second question, in my opinion it might be taking the oldest first. But to verify that put a breakpoint on the For each line in my screenshot above. Run it and when it stops at the break point open the RetrievedEmails datatable in the variable section on the right hand side and you will see the emails listed and find out the order.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi!

     

    Thanks for your answer!


    I implemented the loop as you advised me. It works better than before (well, it worked at least once) but Power Automate still looks quite inconsistent ; one time my six files are correctly copied and the mails deleted, the next time nothing happens (and I had correctly received the new mails), the next time four files are copied and no mails are deleted...


    I know you have nothing to do with it, but these hazards are quite annoying to automate a display that is supposed to work without any external intervention 😕

     

    Anyway, thanks again for your answer, I'll see if I can tweak it to make it work properly !

     

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 233 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 227 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 178

Last 30 days Overall leaderboard