![]() |
Find Method wild card search?
Hello,
I am trying to figure out the following. Is it possible to do a dynamic search on a subject line? This is the subject line: Dictation Job 09121-006, John Doe (TMALA), Acct 3235555555,filename: GR169-477 Can I do something like: myItems.Find("[Subject] = 'Dictation Job *, * *, Acct *,filename: * ") We are using Outlook 2000 I'm very new to VBA. any help will be appreciated. Thanks. |
Find Method wild card search?
Yes, you can use the LIKE predicate, but only with the AdvancedSearch object,
not the Restrict method. Here's a sample from the Outook VBA Reference: Public blnSearchComp As Boolean Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As Search) MsgBox "The AdvancedSearchComplete Event fired" blnSearchComp = True End Sub Sub TestAdvancedSearchComplete() Dim sch As Outlook.Search Dim rsts As Outlook.Results Dim i As Integer blnSearchComp = False Const strF As String = "urn:schemas:httpmail:subject LIKE '%mykeyword%'" Const strS As String = "Inbox" Set sch = Application.AdvancedSearch(strS, strF) While blnSearchComp = False DoEvents Wend Set rsts = sch.Results For i = 1 To rsts.Count MsgBox rsts.Item(i).SenderName Next End Sub -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ " wrote: Hello, I am trying to figure out the following. Is it possible to do a dynamic search on a subject line? This is the subject line: Dictation Job 09121-006, John Doe (TMALA), Acct 3235555555,filename: GR169-477 Can I do something like: myItems.Find("[Subject] = 'Dictation Job *, * *, Acct *,filename: * ") We are using Outlook 2000 I'm very new to VBA. any help will be appreciated. Thanks. |
Find Method wild card search?
Eric, the syntax can be used with Restrict, 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 :) -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Eric Legault [MVP - Outlook]" wrote in message ... Yes, you can use the LIKE predicate, but only with the AdvancedSearch object, not the Restrict method. Here's a sample from the Outook VBA Reference: Public blnSearchComp As Boolean Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As Search) MsgBox "The AdvancedSearchComplete Event fired" blnSearchComp = True End Sub Sub TestAdvancedSearchComplete() Dim sch As Outlook.Search Dim rsts As Outlook.Results Dim i As Integer blnSearchComp = False Const strF As String = "urn:schemas:httpmail:subject LIKE '%mykeyword%'" Const strS As String = "Inbox" Set sch = Application.AdvancedSearch(strS, strF) While blnSearchComp = False DoEvents Wend Set rsts = sch.Results For i = 1 To rsts.Count MsgBox rsts.Item(i).SenderName Next End Sub -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ |
Find Method wild card search?
But that's still only in OL2002 or later, right?
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Ken Slovak - [MVP - Outlook]" wrote in message ... Eric, the syntax can be used with Restrict, 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 :) -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Eric Legault [MVP - Outlook]" wrote in message ... Yes, you can use the LIKE predicate, but only with the AdvancedSearch object, not the Restrict method. Here's a sample from the Outook VBA Reference: Public blnSearchComp As Boolean Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As Search) MsgBox "The AdvancedSearchComplete Event fired" blnSearchComp = True End Sub Sub TestAdvancedSearchComplete() Dim sch As Outlook.Search Dim rsts As Outlook.Results Dim i As Integer blnSearchComp = False Const strF As String = "urn:schemas:httpmail:subject LIKE '%mykeyword%'" Const strS As String = "Inbox" Set sch = Application.AdvancedSearch(strS, strF) While blnSearchComp = False DoEvents Wend Set rsts = sch.Results For i = 1 To rsts.Count MsgBox rsts.Item(i).SenderName Next End Sub -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ |
Find Method wild card search?
Ooh, that's a juicy little tidbit! Thanks Ken.
-- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "Ken Slovak - [MVP - Outlook]" wrote: Eric, the syntax can be used with Restrict, 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 :) -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Eric Legault [MVP - Outlook]" wrote in message ... Yes, you can use the LIKE predicate, but only with the AdvancedSearch object, not the Restrict method. Here's a sample from the Outook VBA Reference: Public blnSearchComp As Boolean Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As Search) MsgBox "The AdvancedSearchComplete Event fired" blnSearchComp = True End Sub Sub TestAdvancedSearchComplete() Dim sch As Outlook.Search Dim rsts As Outlook.Results Dim i As Integer blnSearchComp = False Const strF As String = "urn:schemas:httpmail:subject LIKE '%mykeyword%'" Const strS As String = "Inbox" Set sch = Application.AdvancedSearch(strS, strF) While blnSearchComp = False DoEvents Wend Set rsts = sch.Results For i = 1 To rsts.Count MsgBox rsts.Item(i).SenderName Next End Sub -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ |
Find Method wild card search?
I believe so but I've never tested it with an Outlook 2000 setup.
But it's an interesting undocumented way to get wildcards and other things you can't really do with the Jet syntax without waiting for Outlook 2007 if you don't have to support Outlook 2000. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Sue Mosher [MVP-Outlook]" wrote in message ... But that's still only in OL2002 or later, right? -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx |
All times are GMT +1. The time now is 08:23 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com