View Single Post
  #7  
Old March 16th 06, 09:51 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default automating body text search

Am Wed, 15 Mar 2006 18:17:27 -0800 schrieb Edward:

As I donīt know what doesnīt work, please read this:
http://groups.google.de/group/micros...865987f49346ca

It descripes how to use non default folders in the scope.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Still confused. Any idea why this doesn't work:



Sub SearchUndeliverablesFolder()
'Searches the Inbox
Dim objSch As Search
Const strF As String = "urn:schemas:httpmail:textdescription LIKE

'%'"
Const strS As String = "undeliverables"
Const strTag As String = "GITem"
Set objSch = Application.AdvancedSearch(Scope:=strS, _
Filter:=strF, Tag:=strTag)
End Sub


Public Sub Application_AdvancedSearchComplete(ByVal objSch As Search)
Dim objRsts As Results

Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\UndelResults.txt", True)

MsgBox "The search " & objSch.Tag & "has completed."
Set objRsts = objSch.Results
'Display number in Results collection
MsgBox "There are " & objRsts.Count & "address items"
'Write each member of Results to file
For Each Item In objRsts
a.WriteLine (Item) 'took this out: objRsts.WriteLine Item
Next
a.Close
MsgBox "end of write subroutine", vbOKOnly + vbInformation
End Sub

MsgBox "Finished.", vbOKOnly + vbInformation

Set objNS = Nothing
Set objFolder = Nothing
Set objItem = Nothing
Set objItems = Nothing


End Sub


tHANKS

Ads