wh3resmycar2
wh3resmycar2

Reputation: 305

Excel VBA @SQL String filter

I have been struggling on making this statement a NOT statement:

strfilter = "@SQL=" & Chr(34) & "urn:schemas:httpmail:subject" & Chr(34) & " like '%undeliverable%'"

this strfilter is being used in a items.restrict(strfilter), so obviously it's checking for all emails that contains the word undeliverable.

What I need to do is convert this statement so that it will EXCLUDE all emails with the subject containing the Words "undeliverable".

I've tried this but it returned a parse error:

"strFilter = "@SQL=" & Chr(34) & "urn:schemas:httpmail:subject" & Chr(34) & " NOT '%undeliverable%'"

thanks in advance.

Upvotes: 3

Views: 982

Answers (1)

0m3r
0m3r

Reputation: 12499

The Correct syntax is

Filter = "@SQL=" & " Not " & _
         "urn:schemas:httpmail:subject" & "" & _
         " Like '%undeliverable%'"

Or I prefer this then Like

strFilter = "@SQL=" & " Not " & _
            "urn:schemas:httpmail:subject" & "" & _
            " ci_phrasematch 'undeliverable'"

Upvotes: 1

Related Questions