If attachment already exists then save attachement as something else

I currently have the below in my UiPath bot. The issue with this is that if the filepath already exists then the bot will error out. What I want to do is if the filepath already exists then add a 1 to the end of it and continue on

The image shows a UiPath workflow for retrieving unread emails with attachments from an Outlook folder and saving the attachments to specified folders based on the sender's email address. (Captioned by AI)

Hi @Grey_Angel,

It is better to append the timestamp to the file name.

“fileA_” + Now.ToString(“MMddyyyyhhmmss”)

Regards,
Ranjith Udayakumar

How would I incorporate this into my bot. I am still very new to this

Have it like this in Save to folder

Savepath + “/” + CurrentMail.SenderEmailAddress.Split… once your entire folder path completes + “fileA_” + Now.ToString(“MMddyyyyhhmmss”)

1 Like

Hello @Grey_Angel ,

Can you show us the Save to folder path from the code if possible? we can give you the full syntax.

Regards,
Pradeep Shiv

Savepath + “/” + CurrentMail.SenderEmailAddress.Split(“@”)(1)

Hello @Grey_Angel,

Replace the above Syntax with this,
Savepath + “/” + CurrentMail.SenderEmailAddress.Split(“@”)(1)+“_”+Now.ToString(“MMddyyhhmmss”)

Regards,

Would this make it so that each e-mail would have its own folder??? Right now say I have 100 e-mails with attachments from john@Doe.com. The program will create a Doe.com folder and then save all attachments from those 100 e-mails to that particular folder. If it creates 100 separate folders then that may not work for me because I am trying to create an organized file structure.

I really do appreciate the help.

Hie @Grey_Angel you can do one thing like get that mail id and the split it after @ then it will give you the Doe.com or any other mail Name use that variable to create the folder and after creating the folder use one if condition to check if email id and the folder name contain the same letter move that all file to that folder … and for file you can add date structure like this
“YourFileName”+""+now.tostring("dd-MM-yyyy_HH_mm_ss)
cheers Happy Automation…

Good morning,

I tried to add this syntax and got this error “Expression Activity type ‘VisualBasicValue`1’ requires compilation in order to run. Please ensure that the workflow has been compiled.”

Hi @Grey_Angel

Retype double quotes in that expression

Regards,

1 Like