SearchSubFolders Property
Returns a Boolean indicating whether the scope of the specified search included the subfolders of any folders searched. This property is determined by the SearchSubfolders argument of the AdvancedSearch method and is specified when the search is initiated. Read-only.
expression.SearchSubFolders
expression Required. An expression that returns a Search object.
Remarks
If True, the S earch object searched through any subfolders in the specified filter path.
Example
The following example creates a Search object that contains all items in the user's Inbox with the subject Office Christmas Party. The SearchSubFolders argument is specified as True.
Sub SearchInboxFolder()
'Searches the Inbox
Dim objSch As Search
Const strF As String = _
"urn:schemas:mailheader:subject = 'Office Christmas Party'"
Const strS As String = "Inbox"
Const strTag As String = "SubjectSearch"
Set objSch = Application.AdvancedSearch(Scope:=strS, _
Filter:=strF, SearchSubFolders:=True, Tag:=strTag)
End Sub
Use an AdvancedSearchComplete event procedure to display the results of the search.
Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As Search)
Dim objRsts As Results
MsgBox "The search " & SearchObject.Tag & "has completed. The SearchSubFolders property " & _
"was set to " & SearchObject.SearchSubFolders & "."
Set objRsts = SearchObject.Results
'Print out number in Results collection
Debug.Print objRsts.Count
'Print out each member of Results collection
For Each Item In objRsts
Debug.Print Item
Next
End Sub