DASL to filter mails received in a specific day
Sophia Terry
I would like to use a DASL filter to filter mails received in a specific day.
filterstring = "@SQL=""urn:schemas:httpmail:subject"" LIKE '%" & subject & "%'" & _ " AND ""urn:schemas:httpmail:datereceived"" LIKE '%" & received_date & "%'" & _ " AND ""urn:schemas:httpmail:datereceived"" LIKE '%" & received_date_plus & "%'"The variables are previously defined. "received_date_plus" is the received date plus one day.
01 Answer
The LIKE operator is used for string properties. You need to use < and > to compare date time values (and never use equality operators). Read more about that in the Filtering Items Using a Date-time Comparison article.
filterstring = "@SQL=""urn:schemas:httpmail:subject"" LIKE '%" & subject & "%'" & _ " AND ""urn:schemas:httpmail:datereceived"" > '" & Format(received_date ,"General Date")& "' & _ " AND ""urn:schemas:httpmail:datereceived"" < '" & Format(received_date_plus, "General Date") & "'"Pay attention to the fact that dates should be formatted like Outlook expects them. So, it makes sense to use the Format function available in VBA.
Also you may find the following articles helpful:
- How To: Retrieve Outlook calendar items using Find and FindNext methods
- How To: Use Restrict method in Outlook to get calendar items