Creating Folder name with email received date

I am getting “Assign: Object reference not set to an instance of an object.” error when i am trying to create folder name using the email received date . Can any one help me with this
PFB: SS attached


Does the error always occur or only when you don’t have any attachments?


It always occurs and i am having attachments as well for the emails


Could you please show us the Variable type of Dt?

If it is other than String try to change the type to String


My variable type is string, please find the attached SS

Change the scope of the variable. It’s in the Sequence only

I tried changing the Scope but still getting same error



You can also filter the mails by using filter options…

"UNANSWERED ON " + DateTime.Today.ToString("dd-MMM-yyyy")



I do not want to filter the emails by using dates, I just wanted to create the folder name with the date of the received email

Try “DateCreated”, or “DateReceived”,

Could you please let me know where am i suppose to use this “Date Created” and “Date Received”

Mail.headers(“DateCreated”) OR Mail.headers(“DateReceived”)

Same error exists for both "Mail.headers(“DateCreated”) OR Mail.headers(“DateReceived”) "

PFB : ss

Can you please show me the entire code flow?

Hi You will need to keep the date in string Variable type which will return the date as Wed, 29 Jun 2022 16:46:48 +0530 But you may not want to create your folder with this name to get desired format first convert this string to date then again parse it to string with desired format.

like below screenshot

Complete code is also attached.
CreateFolderFromEmailDate.xaml (10.3 KB)

@k.vandana I hope you are using Get Outlook Mail Message Activity. Please check below steps

  • Click on For Each and make sure you set the argument type to

  • Before assign activity take message box and manually type item.Headers(“Date”) and check the results