View Single Post
  #6  
Old March 16th 06, 02:17 AM posted to microsoft.public.outlook.program_vba
Edward
external usenet poster
 
Posts: 56
Default automating body text search

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

--
Phantom Researcher


"Michael Bauer" wrote:

Am Sun, 26 Feb 2006 17:29:02 -0800 schrieb Edward:

Accessing the result is the one thing and very clear: Use the
AdvancedSearchComplete event. If that fires then the search is complete and
it provides you with a Search object which has a Result property to access
all the result items.

What you want to do with that result is another thing and can't be part of
the help file. You can use e.g. the FileSystemObject of the Scripting
Runtime Library to write any data in a text file.

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


The VBA help isn't too clear on how to access the results of the
AdvancedSearch. Do I need a streamwriter to get the info to a text file,

or
can I access the object directly somehow?

Much thanks.


Ads