Skip to main content

Notifications

Community site session details

Community site session details

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

 

  • Verified answer
    Manuel Nunes Profile Picture
    Microsoft Employee on at
    Re: Flow for email received deletes a file in folder and creates file from the attachement in the same folder as deleted file

    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.

  • Verified answer
    abm abm Profile Picture
    32,464 Most Valuable Professional on at
    Re: Flow for email received deletes a file in folder and creates file from the attachement in the same folder as deleted file

    Hi @AZB0105 

     

    Try to use the below template

     

    image.png

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,635 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow