Restrict format

D

Dave Townsend

Is there any detailed description on the format of queries you can put
into the Restrict method? Ideally I would like to see a BNF for it.

Dave
 
K

Ken Slovak

Only what's available in the Object Browser help, at outlookcode.com and
other Web sites and some examples in various KB articles. I've never seen
any detailed spec covering everything you can do and how to do it.
 
D

Dave Townsend

Ken said:
Only what's available in the Object Browser help, at outlookcode.com and
other Web sites and some examples in various KB articles. I've never
seen any detailed spec covering everything you can do and how to do it.

Very well, I guess it's time to write one. I have a basic bnf together
but I have come across some oddities in my looking into it that maybe
someone can answer.

If I use the restriction "[HomeFaxNumber] = \"\"" it works as expected.

If I use the restriction "[HomeFaxNumber] in \"\"" I get the error
"Unable to parse condition. Error at "in". This suggests to me that "in"
is not a valid keyword, fair enough.

If I use the restriction "[HomeFaxNumber] is \"\"" I get the error
"Unable to parse condition. Error at "". This is odd, surely if "is"
were not a valid keyword, it would appear in the error as it does for
the "in" case?

If I use the restriction "[HomeFaxNumber] like \"\"" I get the error
"Condition is not valid.". Thats a totally different error, maybe a like
comparison can be used. There is certainly a regular expression
comparision in MAPI defined in the same place as all the other comparisons.

Anyway, just some tests, maybe someone out there can shed some light on
these oddities?

Dave
 
K

Ken Slovak

Most of the things you are asking are already answered in the Help for
Items.Restrict in the Object Browser. Have you looked at that? For example,
you can only use the Boolean operators And, Or and Not. Like and In are not
supported.

It almost sounds like what you should be doing is creating an
AdvancedSearch. That can use all sorts of terms such as Like.




Dave Townsend said:
Ken said:
Only what's available in the Object Browser help, at outlookcode.com and
other Web sites and some examples in various KB articles. I've never seen
any detailed spec covering everything you can do and how to do it.

Very well, I guess it's time to write one. I have a basic bnf together but
I have come across some oddities in my looking into it that maybe someone
can answer.

If I use the restriction "[HomeFaxNumber] = \"\"" it works as expected.

If I use the restriction "[HomeFaxNumber] in \"\"" I get the error "Unable
to parse condition. Error at "in". This suggests to me that "in" is not a
valid keyword, fair enough.

If I use the restriction "[HomeFaxNumber] is \"\"" I get the error "Unable
to parse condition. Error at "". This is odd, surely if "is" were not a
valid keyword, it would appear in the error as it does for the "in" case?

If I use the restriction "[HomeFaxNumber] like \"\"" I get the error
"Condition is not valid.". Thats a totally different error, maybe a like
comparison can be used. There is certainly a regular expression
comparision in MAPI defined in the same place as all the other
comparisons.

Anyway, just some tests, maybe someone out there can shed some light on
these oddities?

Dave
 
S

Sledge Hammer via OfficeKB.com

How about this quirk (hasn't anybody confronted su such a one??):

Create an item with subject e.g.:
"DoubleSingled'

Now try to Filter that out :)
These one ain't gonna work (an I have not found a solution that would):
"[Subject]=" + Chr(34) + """DoubleSingled'" + Chr(34)
"[Subject]='""DoubleSingled''"
etc..

Any ideas, please? :)
 
K

Ken Slovak - [MVP - Outlook]

Dim strFilter

strFilter = "[Subject] = "
strFilter = strFilter & Chr(34) & "DoubleSingled" & Chr(39)
 
S

Sledge Hammer via OfficeKB.com

Well, thank you, however this is not a working solution (try it yourself).
Note: I need to filter out a special subject case: when ITEM has a double
quote at the beginning, and a single quote in the end; e.g. (from life):
"AOL" money of customers' <-- how would a Restrict string sound for that?

Your sample simply evaluates to the equivalent string we may write with
escape sequences ("<=>"")
Still, even with your example error triggers: Unable to parse condition.
Error at ""DoubleSingled".
 
K

Ken Slovak - [MVP - Outlook]

You're correct, that one didn't work and neither did any of the other
possibilities I tried.

I guess the only solution is to delete all emails from AOL as soon as they
come in <g>
 
S

Sledge Hammer via OfficeKB.com

Well, that AOL stands only as an example.
The real objective domain is about filtering out all items, which
UserProperty does not match.
And if the value to filter out has such quotes (user can enter anything..:))
, functionality fails at this point..

Thanks for attempts!
 
K

Ken Slovak - [MVP - Outlook]

What I'd probably do is bypass the Outlook restriction/filter methods and
either use a CDO 1.21 MessageFilter object or use Redemption
(www.dimastr.com/redemption) and a MAPITable and filter object. Both of
those could be worked with to set up a filter that could work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top