Download email attachments from outlook, create folders in local directory

Main.xaml (13.0 KB)

Hi All, i am fairly new to UiPath and am wondering if UiPath can download excel attachments from Outlook and create folders when the script is run. I have attached my workflow for reference.
I am able to download the attachment and save into a main folder but the Assign activity used to create folders doesn’t seem to work doesn’t seem to work because of this error message below. (Please uncommented out the Assign activity)
The error message encountered as follows: Message: string was not recognised as a valid Datetime.

Could anyone help me out on this? I followed a youtube video from Andres for this example. Thank you and much appreciated.

1 Like

Kindly show the Assign activity.

Use Create Directory for creating folders.

Hey @zyzz

“/” is not a valid character in the directory.

See the “/” in your Assign for “StrDate”

Update the highlighted “/” to be a “-” or “.” or “_” or another preferred character.

Hopefully this helps,



hi Steve, thank you for your reply, I tried using “-” or leaving it blank and i still get the same error, could it be there’s something wrong with the format i used to parsed in? when i write line it out i see the format is exactly the same as what i have though

Hi Nithin, the assign activity is as follows

1 Like

Hey @zyzz

Its possible.

Replace this:

With this syntax:
CDate(item.Headers(“Date”)).ToString(“ddMMyyyy HHmmss”)

Like this post:



1 Like

Did you print or check in debug mode what is item.Headers("date") ?

the actual date and time stamp appears it’s uncommented out initially

thanks Steve, the create folder activity doesn’t seem to be working though, still looking at that part

Hey @zyzz

So the date format is clearly different from the format you have defined in the Parse function.

Kindly change the format in the second argument of Date.ParseExact function.


What’s the exception message / where are you stuck?

Plenty of people like @Nithinkrishna still here to help :slight_smile:

1 Like

the excel attachment gets saved into the same folder as where i specified it to be without creating new folders as specified with the create folder activity

Thanks nK,
DateTime.ParseExact(item.Headers(“Date”).ToString,“MMddyyyy HH:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“ddMMyyyy HHmmss”)

so basically i need to change the part on “MMddyyyy HH:mm:ss” to mirror this format right:
Thu, 16 Jun 2022 10:47:53 +0800

i tried looking up online for the exact date format online that includes:
, DD MM YYY HH:mm:ss <+GMT timing>
and wasn’t able to look for it - or should there be another format for this?

1 Like

Hey @zyzz

Take a look here for this one:

Suppose If the input is of full format

Strinput = “23/11/2022 02:20:31 +5:30”

Then to get this as Datetime

var_datetime = Datetime.ParseExact(Strinput.ToString, “dd/MM/yyyy hh:mm:ss K”)




I am a bit confused :sweat_smile:

It saves the attachment but in the incorrect folder?

:+1::slightly_smiling_face::tada::100: Cool

There is a format, Let me try to post it for u in few mins.

:ambulance: :sos: [FirstAid] Datatable: Debug & Analysis invalid DateTime Strings / String to DateTime Parsing Issues - News / Tutorials - UiPath Community Forum

Hi! @zyzz ,

Try this way!


it saves the attachment in the main folder as specified here from the variable i created

it does not create new folders as specified in the create folder activity not sure why