Using Wildcards with item.restrict

  • Thread starter Thread starter Ross Culver
  • Start date Start date
R

Ross Culver

I've written a procedure to save attachments to a designate directory upon
receipt of an e-mail. I need to restrict the code to only those e-mails
coming in from (e-mail address removed) since I know the domain won't change but the
user might. I've tried the following:

1) Set myItems = myEmails.Restrict("[SenderEmailAddress] = '*TheXone.net'")
2) Set myItems = myEmails.Restrict("[SenderEmailAddress] = " & chr(42) &
'TheXone.net'")
3) Set myItems = myEmails.Restrict("right([SenderEmailAddress], 11) =
'TheXone.net'")

None worked. Can someone explain to me how to use wildcards in a restrict
method?

Thanks,

Ross
 
No wildcards in Outlook restrictions or filters.

If you are using Outlook 2002 or 2003 you could use the AdvancedSearch
method. That uses SQL syntax and can use a filter string such as "LIKE
%whatever%". You get a Results collection that would have all matches to
your SQL search string.

If you go to the Filter dialog of the customize current view dialog you can
use the Advanced tab to set up a filter condition you want and then on the
SQL tab you view use the DAV search condition that is created from your
filter. That can be copied as your SQL search condition.

See the Help in the Object Browser for more on AdvancedSearch and also
search at www.outlookcode.com for more on that.
 
The SQL tab that Ken is talking about required the QueryBuilder key in the
registry under Outlook's section and I don't think appears by default.

Tom

--
Looking for a good book on programming Exchange, Outlook, ADSI and
SharePoint? Check out http://www.microsoft.com/MSPress/books/5517.asp

This posting is provided "AS IS" with no warranties, and confers no rights.



Ken Slovak - said:
No wildcards in Outlook restrictions or filters.

If you are using Outlook 2002 or 2003 you could use the AdvancedSearch
method. That uses SQL syntax and can use a filter string such as "LIKE
%whatever%". You get a Results collection that would have all matches to
your SQL search string.

If you go to the Filter dialog of the customize current view dialog you can
use the Advanced tab to set up a filter condition you want and then on the
SQL tab you view use the DAV search condition that is created from your
filter. That can be copied as your SQL search condition.

See the Help in the Object Browser for more on AdvancedSearch and also
search at www.outlookcode.com for more on that.




Ross Culver said:
I've written a procedure to save attachments to a designate directory upon
receipt of an e-mail. I need to restrict the code to only those e-mails
coming in from (e-mail address removed) since I know the domain won't change but the
user might. I've tried the following:

1) Set myItems = myEmails.Restrict("[SenderEmailAddress] = '*TheXone.net'")
2) Set myItems = myEmails.Restrict("[SenderEmailAddress] = " & chr(42) &
'TheXone.net'")
3) Set myItems = myEmails.Restrict("right([SenderEmailAddress], 11) =
'TheXone.net'")

None worked. Can someone explain to me how to use wildcards in a restrict
method?

Thanks,

Ross
 
Tom,

Not quite. The QueryBuilder tab is added when you add the QueryBuilder
registry key. That would go under
HKCU\Software\Microsoft\Office\10.0\Outlook in Outlook 2002 or 11.0 in
Outlook 2003.

However, that doesn't create the SQL tab in the custom Filter dialog for a
custom view for Outlook, it displays the QueryBuilder tab. The SQL tab
doesn't appear in Outlook 2000 even if you add the QueryBuilder registry key
and does appear in Outlook 2002 and 2003 even if the QueryBuilder registry
key is not there.




Tom Rizzo said:
The SQL tab that Ken is talking about required the QueryBuilder key in the
registry under Outlook's section and I don't think appears by default.

Tom

--
Looking for a good book on programming Exchange, Outlook, ADSI and
SharePoint? Check out http://www.microsoft.com/MSPress/books/5517.asp

This posting is provided "AS IS" with no warranties, and confers no
rights.
 
Back
Top