restrict with wildcard @SQL syntax

  • Thread starter Thread starter Gordon Prince
  • Start date Start date
G

Gordon Prince

I found this in a post from two years ago:

Restrict [has] a neat little undocumented plus:

strRestrict = "@SQL=" ' then add the filter to that. no spaces.
oItems.Restrict(strRestrict)

So LIKE can be used in a Restrict clause :)
--------------------------------------------------------------
I can't get these phrases to work. Anyone have an idea what would work
here?
strRestrict = "@SQL=[BusinessTelephoneNumber] like '(901) 503-4774%' "

I'm getting an error message:
Cannot parse condition. Error at
"@SQL=[BusinessTelephoneNumber] like '(9
 
It was me :)

The "@SQL" has to be used with DASL syntax property tags. That's the mistake
the poster made.

In this case for the filter on BusinessTelephoneNumber you'd use (all on one
line):
"@SQL=" & Chr(34) & "urn:schemas:contacts:officetelephonenumber" & Chr(34) &
" LIKE = '(901) 503-4774%'"




Michael Bauer said:
What is the guy saying who told you it works?

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Wed, 18 Feb 2009 07:17:03 -0800 (PST) schrieb Gordon Prince:
I found this in a post from two years ago:

Restrict [has] a neat little undocumented plus:

strRestrict = "@SQL=" ' then add the filter to that. no spaces.
oItems.Restrict(strRestrict)

So LIKE can be used in a Restrict clause :)
--------------------------------------------------------------
I can't get these phrases to work. Anyone have an idea what would work
here?
strRestrict = "@SQL=[BusinessTelephoneNumber] like '(901) 503-4774%' "

I'm getting an error message:
Cannot parse condition. Error at
"@SQL=[BusinessTelephoneNumber] like '(9
 
It was me :)

The "@SQL" has to be used with DASL syntax property tags. That's the mistake
the poster made.

In this case for the filter on BusinessTelephoneNumber you'd use (all on one
line):
"@SQL=" & Chr(34) & "urn:schemas:contacts:officetelephonenumber" & Chr(34) &
" LIKE = '(901) 503-4774%'"







What is the guy saying who told you it works?
 : Outlook Categories? Category Manager Is Your Tool
 : VBOffice Reporter for Data Analysis & Reporting
 : <http://www.vboffice.net/product.html?pub=6&lang=en>
Am Wed, 18 Feb 2009 07:17:03 -0800 (PST) schrieb Gordon Prince:
I found this in a post from two years ago:
Restrict[has] a neat little undocumented plus:
strRestrict = "@SQL=" ' then add the filter to that. no spaces.
oItems.Restrict(strRestrict)
So LIKE can be used in aRestrictclause :)
--------------------------------------------------------------
I can't get these phrases to work. Anyone have an idea what would work
here?
strRestrict = "@SQL=[BusinessTelephoneNumber] like '(901) 503-4774%' "
I'm getting an error message:
Cannot parse condition. Error at
"@SQL=[BusinessTelephoneNumber] like '(9- Hide quoted text -

- Show quoted text -

Worked without the "=" after the LIKE.
"@SQL=" & Chr(34) & "urn:schemas:contacts:officetelephonenumber" & Chr
(34) &
" LIKE '(901) 503-4774%'"

Thanks.
 
It was me :)

The "@SQL" has to be used with DASL syntax property tags. That's the mistake
the poster made.

In this case for the filter on BusinessTelephoneNumber you'd use (all on one
line):
"@SQL=" & Chr(34) & "urn:schemas:contacts:officetelephonenumber" & Chr(34) &
" LIKE = '(901) 503-4774%'"







What is the guy saying who told you it works?
 : Outlook Categories? Category Manager Is Your Tool
 : VBOffice Reporter for Data Analysis & Reporting
 : <http://www.vboffice.net/product.html?pub=6&lang=en>
Am Wed, 18 Feb 2009 07:17:03 -0800 (PST) schrieb Gordon Prince:
I found this in a post from two years ago:
Restrict[has] a neat little undocumented plus:
strRestrict = "@SQL=" ' then add the filter to that. no spaces.
oItems.Restrict(strRestrict)
So LIKE can be used in aRestrictclause :)
--------------------------------------------------------------
I can't get these phrases to work. Anyone have an idea what would work
here?
strRestrict = "@SQL=[BusinessTelephoneNumber] like '(901) 503-4774%' "
I'm getting an error message:
Cannot parse condition. Error at
"@SQL=[BusinessTelephoneNumber] like '(9- Hide quoted text -

- Show quoted text -

Here's my final code with some "OR" clauses included:
strPhoneCriteria = "@SQL=" & Chr(34) &
"urn:schemas:contacts:officetelephonenumber" & Chr(34) & " LIKE '" &
strPhone & "%'" & _
" OR " & Chr(34) &
"urn:schemas:contacts:homePhone" & Chr(34) & " LIKE '" & strPhone &
"%'" & _
" OR " & Chr(34) &
"urn:schemas:contacts:mobile" & Chr(34) & " LIKE '" & strPhone & "%'"
& _
" OR " & Chr(34) &
"urn:schemas:contacts:otherTelephone" & Chr(34) & " LIKE '" & strPhone
& "%'"
 
Sorry, that was a typo putting in that extra "=" character.




<snip>
Worked without the "=" after the LIKE.
"@SQL=" & Chr(34) & "urn:schemas:contacts:officetelephonenumber" & Chr
(34) &
" LIKE '(901) 503-4774%'"

Thanks.
 
How can I use a wildcard in the DASL syntax of the Restrict Method

strRestrict = "@SQL=urn:schemas:httpmail:sender LIKE '*Smith*'"
Set myItems = myMail.Restrict(strRestrict)

The * causes the code not to work.
 
Back
Top