Save Email Attachments and Rename

Hi, Please help me to download the email attachments (single) and rename wile saving to the local path. The name should be taken from email subject line with condition (i.e. name should be starting after “[” and ending before “]” which is already available in my subject line and in addition to add the date of receipt of the email. Please help me.

Hi @Ahamed_Salih,

Use save attachment activity
Pass mail object in Mail Message field.

In FolderPath Pass
“YourFolderpath”+system.Text.RegularExpressions.Regex.Match(mail.Subject,"(?<=[).+(?=])").Value+"_"+mail.Headers(“Date”).ToString+".xlsx" instead of .xlsx mention your file type

if you want to save n different date format than use this


Hi Akshay, thank you very much for your reply, I am really sorry to say that, I am very new to uipath, if you guide me step by step. it will be very helpful.

I followed your instruction as below.

No results

My email subject is “Payment Advice - Advice Ref:[GLVB18668268] / Priority payment / Customer Ref:[GTO11-1811ELM]” having one attachment, I need the file name as GTO11-1811ELM-20112020

Please help me.

@Ahamed_Salih - in “Save to folder”, write Project Folder as “Project Folder” (with double quotes).

Should be like:
"Project Folder"+system.text.Re...

Hello @Ahamed_Salih,

Are you using studioX,

Can you please print the path using writeline or something so we can see what are the illegal character’s?




Hello @Ahamed_Salih,

Above save attachments activity, can you please put a writeline activity and in writeline activity put the exact folder path value and run the process once. So we can know whats the output of the folder path value.

Hi @Akshay07

It is not working, need your help.

@Ahamed_Salih - Instead of .value in the regex, please try .tostring…I just tried something in one of my project and it worked…

Example: "Output is: " + System.Text.RegularExpressions.Regex.Match(“Input String”,“RegexPattern”).ToString

@Ahamed_Salih the “Save Email Attachments” activity in StudioX does not allow you to change the name of the file while it’s saving the attachments. So the basic format you want to follow is:

  • Save the attachments to a folder that will be empty to start
  • If you click the “+” in the designer, there will be sample of how “To add date to folder file names” which will show you how to rename a file to include the date from Excel.
  • However in your case, you’ll want to use the properties from the “CurrentMail” of “Subject” and “Date (as text)” instead of the values from the built in Excel Notebook file.
  • The activity that actually renames it is a “Move” file, so you can choose to place these now “processed” emails into a different folder while renaming them.