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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Flow for email receive...
Power Automate
Answered

Flow for email received deletes a file in folder and creates file from the attachement in the same folder as deleted file

(0) ShareShare
ReportReport
Posted on by 12

My current flow is as follows but my Excel file that is created is corrupt and no delete of the file?

AZB0105_0-1616675520670.png

AZB0105_1-1616675588205.png

 

Categories:
I have the same question (0)
  • Verified answer
    abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @AZB0105 

     

    Try to use the below template

     

    image.png

  • Verified answer
    Manuel Nunes Profile Picture
    Microsoft Employee on at

    Hi @AZB0105 

    Thank you for reaching out.


    I understood that when you receive an e-mail with a file attached and after checking a condition, you firstly want to delete an already existing file in OneDrive and proceed to create a new one containing the attached file from the email.
    Currently, the file is not being deleted (issue 1) and the Excel that you create is corrupted (issue 2).


    I tried to reproduce the errors on my side and I found that:

     

    Issue 1: Delete of the statically specified file Report (2).xls
    I was able to delete the file with no problem. Using the folder icon in the File textbox, I manually chose the file in OneDrive I wanted to delete, and then made sure the file was actually placed in that directory in OneDrive.

    If you still encounter the same behaviour, please try to delete and create the action again.

     

    flow2_a.png


    Issue 2: Created Excel from Email attachment is corrupted
    Currently, Power Automate does not allow for the creation of an Excel file in OneDrive passing on directly the dynamic content "Attachment Content" to the "Create file" action. A workaround might be to use the "Get attachment (V2)" action after receiving the email and then use the "Content Bytes" dynamic content from that action, when creating the OneDrive file.
    Below is a flow example:

    flow2.png


    Please, note that this implementation only works when you receive 1 attachment on the e-mail. The action "Get Attachment (V2)" will prompt the use of the "Apply to each" control action to check every attachment on the received e-mail.
    In case you receive more than 1 attachment, by the time the flow is processing the 2nd attachment, it might fail because the file Reports (2).xls has been already deleted.

    To get around this, you can make sure that you only process email's containing 1 attachment, using a condition as I did in the above flow.

     

    Otherwise, the template @abm suggested might also be an option.

     

    Looking forward for your reply.

     

    Best regards,
    Manuel Nunes

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard