Get outlook mail messages filter


I have searched the forums for many threads like this, but is unable to get what i need working.

I need to filter emails based on the time after ticket submission and the subject title.

I have a datetime variable(DT_ticket) saved when submitting a ticket.
The subject contains “Ticket number:”

The following filter is not working:
“[ReceivedTime] > '”+DT_Ticket.ToString(“MM/dd/yyyy hh:mm tt”)+"’" +“AND [Subject] LIKE ‘ticket number:%’”

What should be the right syntax?

Thank you.

anyone? :frowning:

Hi @tzj,

I tried for similar scenario a month back. It didn’t work for me too.
I think we can have only one filter option at one instance. Can anyone please correct me if I’m wrong.

Alternatively, you can give first option in the filter and once mailMessages are retrieved , take a for each loop and check with if condition whether a particular mail message item has " [Subject] LIKE ‘ticket number:%’” " or not and so on.

If this is not working , let’s wait for others to respond here.


Try the below DASL Query:
"@SQL=(""urn:schemas:httpmail:datereceived"" >= '"+DT_Ticket.ToString(“MM/dd/yyyy hh:mm tt”) +"' AND "urn:schemas:httpmail:subject" LIKE '%ticket number:%')"

something wrong with expression i guess, it’s not working