Skip to main content

Notifications

Community site session details
Power Automate - Building Flows
Answered

How to automatically save email attachments to OneDrive WITHOUT overwriting existing files

Like (0) ShareShare
ReportReport
Posted on 3 Oct 2021 00:25:37 by

When automatically saving attachments from email into OneDrive, using the Power Automate Create File function, the new file will automatically overwrite the existing file.  Create File does not append a serial number or otherwise handle the duplication in a lossless way. I don't see any easy way to automatically assign a unique name to new files, so that the existing ones are not overwritten.

I assume  one could get the names of all the files in the folder (hundreds? thousands?), check the list for duplicate file names, and if necessary add a serial number to generate a unique name. That's a lot more Power Automate code than I am prepared to learn, write, and debug.

One can reduce the problem somewhat by prepending to the filename the time the file was received, but that results in long clunky file names, and does not successfully handle multiple attachments from the same email that just happen to have the same file name.  

Is there any solution to this issue?  It seems very limiting to the general usefulness of the email-to-OneDrive flow.

  • Verified answer
    VJR Profile Picture
    7,635 on 05 Oct 2021 at 04:08:52
    Re: How to automatically save email attachments to OneDrive WITHOUT overwriting existing files

    Hi @Anonymous 

     

    You need to add two branches. One if the move was a success and another if it was not.

     

    - Add another move after the first move

    This left branch is in case if the first move failed

    This time give a new name (maybe a datetimestamp suffix).

    The second move is to rename the file along with the move.

     

    VJR_0-1633406316793.png

     

    - Select the plus sign below the original move and choose "Add a parallel branch"

    Now you have the right hand side branch. Choose what you want to do in case the original move was a success.

     

    - See the red box marked with the dotted arrow in the above screenshot on the LHS.

    To achieve that click on the three dots in the second move -> Then click "Configure run after" -> Then select as below

     

    VJR_1-1633406650039.png

    This will tell the flow to run the LHS branch only when the first move has failed.

    You can also select "is skipped" or "has timed out" depending on the needs of your project requirements.

     

    It will be difficult for me to show the error handling here :). So you might want take a look at some videos and articles on this topic.

     

    Hope this should get you going.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Automate - Building Flows

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 200 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 192 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 177

Overall leaderboard