It works here.
Search code:
Sub SalesSearch()
Dim objSch As Search
Dim strF As String
Dim strS As String
Dim strTag As String
strF = Chr(34) & "urn:schemas:httpmail:subject" & Chr(34) & " LIKE
'%Order%'"
strS = "'//Mailbox - Sales'" 'search Sales mailbox and all subfolders
strTag = "DomainSearch"
Set objSch = Application.AdvancedSearch(Scope:=strS, Filter:=strF, _
SearchSubFolders:=True, Tag:=strTag)
Set objSch = Nothing
End Sub
Event handler:
Public Sub Application_AdvancedSearchComplete(ByVal SearchObject As Search)
Dim rsts As Outlook.Results
If (SearchObject.Tag = "DomainSearch") Then
Set rsts = SearchObject.Results
MsgBox "Search returned " & rsts.Count & " items"
End If
Set rsts = Nothing
End Sub
This was run in Outlook VBA. The event handler was placed in the
ThisOutlookSession class module, the search code was run from a code module.
It takes a bit of time for the search to complete, depending on subfolders
count and number of items, but it worked.
--
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
"Howard" <(E-Mail Removed)> wrote in message
news:C08FF2BC-D91F-4382-8629-(E-Mail Removed)...
> Okay, I've figured out how to get the AdvancedSearch function to work.
> However, the Application_AdvancedSearchComplete event isn't firing, so the
> search results aren't getting passed back to the calling subroutine. Can
> anyone hazard a guess as to what I'm doing wrong?
>
> "Howard" wrote:
>
>> Understood. But how can I get it to search a mail store other than my
>> own?
>> I've tried doing an Application.logon to a profile associated with one of
>> the
>> shared inboxes I'm trying to search but the AdvancedSearch seems to go
>> into
>> an endless loop.