I'm trying to do an advanced search in MS Outlook 2010 for a MailItem using advanced search. The issue I'm having is searching through subfolders. I know that the third argument in the function is a boolean for searching through those folders, but I'm having no luck. So what I want to do is have an array for the scope (the first argument) which lists the folder names.
The array is very easy when searching main folders ('Inbox','Contacts','Calendar'), but the issue is how to use that same format to list subfolders, for instance, "'Inbox\Subfolder1','Inbox\Subfolder2'". Simply listing the subfolder names in the array as stand alone names causes the function to fail. How could I accomplish listing these names? Or is there any easier way to accomplish the same search without needing to do this? Below is what I have so far with our the Declarations of variables, etc...
The array is very easy when searching main folders ('Inbox','Contacts','Calendar'), but the issue is how to use that same format to list subfolders, for instance, "'Inbox\Subfolder1','Inbox\Subfolder2'". Simply listing the subfolder names in the array as stand alone names causes the function to fail. How could I accomplish listing these names? Or is there any easier way to accomplish the same search without needing to do this? Below is what I have so far with our the Declarations of variables, etc...
Code:
Const strScope As String = "'Inbox', 'Inbox\SubFolder1', 'Inbox\SubFolder2','Inbox\SubFolder3'" 'Need help here
strSubject = oMail.ConversationTopic
strF = "urn:schemas:mailheader:subject = '" & strSubject & "'"
strTag = "SubjectSearch"
Set objSch = Application.AdvancedSearch(strScope, strF, True, strTag)