cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Super User
Super User

Save Outlook Attachments And Guard Against Duplicate File Name Overwrite

I have created this post in the event that you may want to guard against duplicate file names being saved in SharePoint or OneDrive when generated from an email.

 

Let's just say you get a csv file named "report.csv" emailed to you every day. You want to save that file from Outlook, to SharePoint but not overwrite the previous file of the same name.

This makes it tricky to use "Get email" and "Attachments Name" from dynamic data as you would have to rename the file yourself in SharePoint to avoid the file overwrite on the next Flow run.

 

Full details at the link below.

 

https://www.alanps1.io/power-platform/flow/flow-excel-formats-only-save-new-email-attachments-to-sha...

 

EDIT: For anyone who may have issues with dots or periods in their file name then please see this post as an add on.

 

https://www.alanps1.io/power-platform/flow/flow-strip-dots-and-special-characters-from-file-names/

 

Thanks, Alan


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


16 REPLIES 16
frixel
Level: Powered On

Re: Save Outlook Attachments And Guard Against Duplicate File Name Overwrite

Hi,

I try to get this Flow working, but I fear that some commands in the Flow have now been renamed. and the action "outputs" there are now 2 of them. you now have the choice between action outputs and trigger outputs. (what should it be?) And what needs to be filled in with the 2nd variable where you say you want to fill it in later?

 

I have now a error on:

The template validation failed: 'The repetition action(s) 'apply_to_each_Attachment_on_the_email' referenced by 'inputs' in action 'Compose' are not defined in the template.'.

 

This is what i now have.

flow3.png

 

Super User
Super User

Re: Save Outlook Attachments And Guard Against Duplicate File Name Overwrite

Hi @frixel 

The "outputs" (in my example):

 

outputs(‘Compose_FileExtension’)[0]

You need to put your "Set Variable" and your "Create file" inside the "Yes" branch.

If you mirror this image and the details in the post you shouldn't find issue. If you keep your naming convention the same, you can even copy and paste the expressions I have used. They are all in the blog were required.

 

Here is the complete Flow (from blog post):Capture-333.png

This post and the Flow were created 3 days ago, nothing has been renamed by Flow. Only the use of clicking the elipses (...) and renaming each action as I stepped through the process to make it easier to understand.

It would be best that you delete what is outwith the "Yes" branch and name your "Compose" to "Compose FileExtension" in the way I have just described then continue to follow the blog post. Then recreate the "Set Variable FileExtension" and "Create file" within the "Yes" branch.

 

Also - triggers are what start the Flow off, there is only ever one of them. In this case "On new email (webhook).

Actions, are what come after the trigger. Everything else is an action.

 

If you have found my posts helpful, please mark them thumbs up.

 

If this post has solved your problem, please click "Accept as Solution".

Any other questions, just ask.

Thanks, Alan

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


frixel
Level: Powered On

Re: Save Outlook Attachments And Guard Against Duplicate File Name Overwrite

I just get the error message with typing:
split (items ('apply_to_each_Attachment_on_the_email') ['name'], '.')

 

What do i wrong?

 

flow4.png

Super User
Super User

Re: Save Outlook Attachments And Guard Against Duplicate File Name Overwrite

Hi @frixel . It looks like your naming convention ...

You have called your "Apply to each" , "Apply to each 2" in the first image.

Assuming you have now renamed it (you haven't included it in the last image so I am guessing at this part), it needs to be exactly the same as mine, including capitalisation.

My "Apply to each" action is called Apply to each Attachment on the email

That allows me to use:  "split(items(‘Apply_to_each_Attachment_on_the_email’)[‘Name’], ‘.’)"

Yours would need to match identically, if it doesn't, you will need to change it to suit.Capture-354.png

So, if you have named it "Apply to each 2" "split(items(‘Apply_to_each_2’)[‘Name’], ‘.’)"

 

Thanks, Alan


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


frixel
Level: Powered On

Re: Save Outlook Attachments And Guard Against Duplicate File Name Overwrite

Oke thanks, but sorry just a question.

 

I don`t get it on the right way in the Flow.

It does not recognize the split command.

 

flow5.png

 

 

Super User
Super User

Re: Save Outlook Attachments And Guard Against Duplicate File Name Overwrite

Hi @frixel 

You need to add it as an expression:Capture-355.png

Thanks, Alan


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


frixel
Level: Powered On

Re: Save Outlook Attachments And Guard Against Duplicate File Name Overwrite

Yes, i know but when i do that also the error:

The exeption is invalid.

 

flow6.png

Super User
Super User

Re: Save Outlook Attachments And Guard Against Duplicate File Name Overwrite

Hi @frixel 

Try and copy and paste this:

split(items('Apply_to_each_Attachment_on_the_email')['Name'], '.')

 

Thanks, Alan

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


frixel
Level: Powered On

Re: Save Outlook Attachments And Guard Against Duplicate File Name Overwrite

Yes, now it is ok.

How? i think the seperators where wrong?

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Users Online
Currently online: 296 members 4,645 guests
Please welcome our newest community members: