#email

Hi All,

How to get emails at the given time using imap/outlook. For example: Get all emails received at 4:00 PM.

Thanks…

1 Like

Refer here:

1 Like

Hi,

I tried by following steps, still not able to get. Please find the xaml file attached.

Thanks…Main.xaml (5.9 KB)

@Amreen_Zabi
First, change the TypeArgument parameter of the For Each activity to be System.Net.Mail.MailMessage. This helps in two ways: UiPath will suggest methods of the class when typing which makes programming easier, and you don’t have to convert the item every time you want to use a method.

Then item.Headers.Item("DateRecieved") will give you the received date and time. You can filter this however you want. If you’re trying to find any emails that were sent in the 4pm hour you could doitem.Headers.Item("DateRecieved").Contains(" 16:") in your If condition or if you want ones from a certain date you can use that to search instead. You could use regex to search even more precisely.

It’s usually good to rename the ‘item’ variable in the For Each to something more specific. This can make debugging easier in large processes and it looks nicer (in my opinion) when you’re referencing the variable.

If you want to filter the emails before reading them (like the example I linked above) then you put the condition in the Filter parameter of the Get outlook mail messages activity. That’s where you would use something like "[ReceivedTime]>= ’ " +...

1 Like

@DanielMitchell Thanks for the info, will try it and update.

2 Likes