Home > Blockchain >  DASL to filter mails received in a specific day
DASL to filter mails received in a specific day

Time:06-04

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.

CodePudding user response:

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:

  • Related