Getting Exception while using FilterExpression for "ReceivedTime" in IMAPGet Mail Messages

I am using GetIMAPMailMessage activity to read top 5 emails from Gmail. Getting all the data from emails like sender, subject, date etc.
When I try to use FilterExpression with below two statements, both of them are giving exception

“[ReceivedTime]>‘09/20/2021 18:14’” or
“[ReceivedTime] > “ +Now.AddDays(-1).ToString(“MM/dd/yyyy hh:mm tt”)+””

Getting below exception -

The IMAP server replied to the ‘SEARCH’ command with a ‘BAD’ response: Could not parse command

What am I doing wrong?

@Shuchi_Gupta

Try below expression.

        “[ReceivedTime] > ‘”+ Now.AddDays(-1).ToString(“dd-MM-yyyy”)+"’"

@lakshman

Nope, again giving same exception

@Shuchi_Gupta

Try below steps.

  1. Use Get IMAP Mail Message activity to read mails and will give output as List of Mail Messages.

  2. And then try below expression.

LstMailMessages = LstMailMessages.Where(Function(x) CDate(x.Headers(“Date”)).ToString("dd-MM-yyyy) > Now.AdsDays(-1).ToString("dd-MM-yyyy").ToList

@lakshman - I got the solution. Since I am using GetIMAP Mail Activity, below filter worked
in filterExpression -

If I want to fetch emails since 20th Sept 2021 -

“SINCE 20-Sep-2021”

or If I want to fetch emails since 2 days -

"SINCE "+ DateTime.Today.AddDays(-2).ToString(“dd-MMM-yyyy”)

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