How to Capture the Day [ Sunday, Monday,etc] from received Email?


Dear All,
Can some on e help on “How to Capture the Day [ Sunday, Monday,etc] from received Email?”

Thank you…


@Pavan_Kodali Store recieved date in variable and use following method





Hi @Pavan_Kodali,

Try like the following,



Thanks a lot Sarathi.
This helped me a lot - but please kindly do me one more favour.

I need to capture the Time from the Received Email & Need to check the Below Condition -
Whether Email Received time comes under a time intervel of 3PM To 5PM..

If Email Received between 3 to 5PM, then BOT should Run.

Please help o nthis.

many thanks & thanks Again.
Much appreciated all your kind help n support…


Working on it for your another post, give me sometime.


Hey… You are the Real Robot Master…!!!
I will wait for your response…


you should have two variables with TimeSpan datatype called startTimeSpan and endTimeSpan, then

inside assign activity have it startTimeSpan = New TimeSpan(2, 00, 00)
another assign activity endTimeSpan = New TimeSpan(3, 00, 00)

then inside a If

Convert.ToDateTime(mail.Headers(“Date”).ToString).TimeOfDay > startTimeSpan and Convert.ToDateTime(mail.Headers(“Date”).ToString).TimeOfDay< endTimeSpan


Thanks a lot Saradhi . now i am able to start my Project Activity.
Many Thanks.

But have one basic doudt - How Bot wil identify the Time when AM & PM.
In Outlook Messages, i am able to see like "Thu 05-07-2018 03:00 PM.

Now i am using below to get the Time:

When i am trying to compare this with : New TimeSpan(3, 00, 00)
So here how system will compare? say, if it is 3AM or 3PM


But just print all the timespan and see, I think it will be converted to 24hrs format, I can see 13:00, 14:00 something which is in 24hrs format. Let me know if still you have problem.

I have checked, my mail received 1:39 PM, but when my code starts check it, it been converted to 13:38:40.
so no issue will occur, since we have used timeofday function.


Okay i just started my Execution. I will ask for your help if anything goes wrong…


Dear Robot Master,
It was Awesome, Excellent.
Bot Successfully Executed with the Conditions like “On Perticular Day AND Perticular time Interval” - It was so good. Much Appreciated all your kind help.

Here i attached my File.
For Unit Test Purpose i made conditions like:
Day = Wednesday
Time = 6Pm to 11 Pm.

Thanks a lot & thanks again…

Please do me a Favour - i have gone thourgh the Academy Videos BUT did not find this type of Information. Please help me in Educating these…

Pavan.DateTime-Pavan.xaml (12.0 KB)



We can try like this also
First get the Mails which are all received today by giving Filter String in Filtered Property.

Let us take the Mail Collection as List A

If the count is greater than Zero then you can use Linq

 List B = (From p in In List A
Where DateTime.ParseExact(p.ReceivedTime.ToString("MM/dd/yyyy hh:mm tt"),"MM/dd/yyyy hh:mm tt",System.Globalization.CultureInfo.None)>=DateTime.ParseExact(System.DateTime.Now.Date.ToString("MM/dd/yyyy")+" "+"03:00 PM","MM/dd/yyyy hh:mm tt",System.Globalization.CultureInfo.None) and DateTime.ParseExact(p.ReceivedTime.ToString("MM/dd/yyyy hh:mm tt"),"MM/dd/yyyy hh:mm tt",System.Globalization.CultureInfo.None)<=DateTime.ParseExact(System.DateTime.Now.Date.ToString("MM/dd/yyyy")+" "+"05:00 PM","MM/dd/yyyy hh:mm tt",System.Globalization.CultureInfo.None)
Select Ctype(p,MailItem)).ToList

If List B.Count >0 you can start the bot.

I have not tested the code, but I thought we can do like this



HI saradhi,
Are are there any mistakes in my code?


Yes looks good to me