Get Outlook Messages Filter for Specific Date

I’ve used several different methods of filtering for a specific date with the Get Outlook Messages activity, but none of them seem to be filtering correctly. It’s returning the incorrect number of emails. I don’t know if I’m experiencing limitations of UiPath or if there are inherent limitations due to time zones.

For example, I’ve tried filtering for the date two days ago. Here are a couple of methods I’ve tried:

"[ReceivedTime]>= ’ " + now.AddDays(-2).ToString(“D”) + " ’ AND [ReceivedTime]<= ’ " + now.AddDays(-1).ToString(“D”) + " ’ "

"[ReceivedTime]>= ’ " + now.AddDays(-2).ToString(“MM/dd/yyyy”) + " ’ AND [ReceivedTime]<= ’ " + now.AddDays(-1).ToString(“MM/dd/yyyy”) + " ’ "

I’ve also tried to adjust the -2 and -1 in now.AddDays() in case UiPath can recognize fractions of days:

"[ReceivedTime]>= ’ " + now.AddDays(-2.5).ToString(“MM/dd/yyyy”) + " ’ AND [ReceivedTime]<= ’ " + now.AddDays(-1.5).ToString(“MM/dd/yyyy”) + " ’ "

I’ve also tried using the specific date-time:

"[ReceivedTime] >= ‘11/27/2018’ AND [ReceivedTime] <= ‘11/27/2018 23:59:59’ "

It’s really strange because if I use a correct filter that has worked for others within these forums, the activity will return exactly 14 emails from the date prior to the day I’m trying to retrieve. Emails are continuously being sent to the email folder. So I don’t understand why it’s returning more emails than what was received during the specified day.

Not sure why the filters are not working in your case.
Have you tried adding a secondary check IF condition in looping the mail messages if that works at least.
in IF condition : try to use MailItem.ReceivedTime >= Now…

Regards,
Karthik Byggari

Hey @Ben88

please try this Query and let me know :slight_smile:

“[ReceivedTime] >= '”+now.AddDays(-2).Date.ToShortDateString+"’ AND [ReceivedTime] <= ‘"+now().Date.ToShortDateString+"’"

Regards…!!
Aksh

I added below in to my robot and get the mail that received date >= ‘2019/01/01’

“[ReceivedTime] >= '” +DateTime.Parse(now.tostring(now.year.tostring + “/01/01”)).ToString(“MM/dd/yyyy”) + “’”

@aksh1yadav how we can do in IMAP as item.header(“Date”) is showing different format like
Mon, 23 Dec 2019 12:32:40 -0800 (PST) which is not recognized by datetime
can i get date by (created at) in gmail?

Hey @vaneet_kumar

There is no such key exists
for your reference see below are Gmail header keys :slight_smile:

Delivered-To
Received
X-Received
ARC-Seal
ARC-Message-Signature
ARC-Authentication-Results
smtp.mailfrom
Return-Path
Authentication-Results
DKIM-Signature
X-Google-DKIM-Signature
X-Google-Smtp-Source
X-GM-Message-State
X-Account-Notification-Type
X-Notifications
Received-SPF
Feedback-ID
MIME-Version
From
To
Date
Subject
Content-Type
Content-Transfer-Encoding
Message-ID
Subject
Feedback-ID
Uid
Folder
PlainText
HtmlBody

You can parse it like below, It will work for you :slight_smile:

DateTime.ParseExact(item.Headers(“Date”).Replace(" (PST)",""),“ddd, d MMM yyyy HH:mm:ss zzzz”,System.Globalization.CultureInfo.InvariantCulture).ToLocalTime.ToString

Regards…!!
Aksh

1 Like

Thanks Aksh,

create date

I am talking about Created on Date can we fetch it somehow by any reference?

Regards
Vaneet

hey @vaneet_kumar

Yes you can use Received property

note -

Regards…!!
Aksh

Actually both dates are different.
Item.headers(“Date”) is different from “Created on” date as shown in pic above circle in red mark.
item.headers(“Date”) is in PST and “Created on” date is showing in IST format.

So just a query is there any way to fetch Created on Date?

Thanks Aksh.