Tag Property
Returns a String specifying the name of the current search. The Tag property is used to identify a specific search.
expression.Tag
expression Required. An expression that returns a Search object.
Remarks
The Tag property is set by the AdvancedSearch method when the Search object is created.
Example
The following example searches through the user's inbox for all items that do not have a flag. The name "FlagSearch", specified by the Tag property, is given to the search.
Sub SearchForFlags()
'List all items in the Inbox that do NOT have a flag:
Dim objSch As Search
Const strF As String = "urn:schemas:httpmail:messageflag = 0" & _
" OR urn:schemas:httpmail:messageflag IS NULL"
Const strS As String = "Inbox"
Set objSch = _
Application.AdvancedSearch(Scope:=strS, Filter:=strF, Tag:="FlagSearch")
End Sub
The following example uses the AdvancedSearchComplete event to capture the outcome of the search. The Tag property of the search is displayed to notify the user which search has completed.
Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As Search)
Dim objRsts As Results
MsgBox "The search " & SearchObject.Tag & "has completed."
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