Filter outlook mail message return empty/null

Im trying to filter my outlook mail message for today from 8AM to 9AM. However, it returned null when the email is there and is still unread.

“[Received] >= '” + DateTime.Today.ToString(“d”) + " 08:00AM’ AND [Received] < ‘"+ DateTime.Today.ToString(“d”) + " 09:00AM’"

This one taken from UiPath docs

Hi @aqiffm

Could you check with the below expression

"[ReceivedTime] >= '" + DateTime.Today.ToString("MM/dd/yyyy 08:00:00") + "' AND [ReceivedTime] <= '" + DateTime.Today.ToString("MM/dd/yyyy 09:00:00") + "'"

Note : Don’t forget to mention the specific folder where you want to retrieve mails.

Hope it helps!!

Hi @aqiffm

Try this

"[Received] >= '" + DateTime.Today.ToString("MM/dd/yyyy 08:00 tt") + "' AND [Received] < '" + DateTime.Today.ToString("MM/dd/yyyy 09:00 tt") + "' AND [IsRead] = false"

I have tried it and it still returns nothing. I already specify the email folder. Ive tried different outlook filter and returns something.

Example: “@SQL=”“urn:schemas:httpmail:subject”" like ‘%CTT%’"

With the same email, i try to check the date format using mailMessage.Headers(“Date”), the format is this “Thu, 04 Jan 2024 08:29:58 +0800”

ive tried this and weirdly its not working. i used different type of email filter and it returns something.

Example: “@SQL=”“urn:schemas:httpmail:subject”" like ‘%CTT%’"

@aqiffm

Can you please check on this

Could you give me much information about this then we will try to give the proper solution for your query. @aqiffm

I want to query email for today from 8AM to 9AM

Hi @aqiffm

Please try the below Filter condition it’s working

"[ReceivedTime] >= '" + DateTime.Today.ToString("d") + " 08:00AM' AND [ReceivedTime] <= '" + DateTime.Today.ToString("d") + " 09:00AM'"

Regards,

Thank you for your effort everyone, using the filter is not working eventho I try all the suggestion where I suspect the bug on this. Hence I do the alternative way on this. The steps are as follows:

  1. Filter by subject email and get the top 5 email
  2. For each loop the email, and compare each of them which has the same date and time is >= 8AM and <= 9AM
  3. and among the filtered email, i will compare among them to get the oldest email

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.