Hi,
here is a sample for iterating through the folders with CDO 1.21
(optional installation). You need to logon a MAPI Session. The object
hierarchy for the first method´s
argument "oFolders" is: Session.InfoStores(i).RootFolder.Folders.
In the last method you can search in each item for your keywords. For
the CDO properties please visit
www.cdolive.com/cdo10.htm.
(You could use the OOM instead of CDO, of course, whích is easier to
handle - and very slowly...)
'-----------------------------------------------------------------------
-----
' Procedure:LoopInfoStoreFolders
' DateTime :04.03.2005 07:18
' Author :Michael Bauer
' Purpose :Loop through the Mapi folders hierarchy of one InfoStore
' for handling each folder item
'-----------------------------------------------------------------------
-----
Public Sub LoopInfoStoreFolders(oFolders As MAPI.Folders, _
ByVal bRecursive As Boolean _
)
Dim oFld As MAPI.Folder
' Loop through all folders.
For Each oFld In oFolders
' Loop through folder items
LoopItems oFld.Messages
If bRecursive Then
' Call this function again for going _
deeper into the object hierarchy.
LoopInfoStoreFolders oFld.Folders, bRecursive
End If
Next
End Sub
Private Sub LoopItems(oItems As MAPI.Messages)
Dim obj As Object
For Each obj In oItems
Select Case True
Case TypeOf obj Is MAPI.Message
HandleMessage obj
Case TypeOf obj Is MAPI.AppointmentItem
' Another method for handling AppointmentItems
' etc.
End Select
Next
End Sub
Private Sub HandleMessage(oItem As MAPI.Message)
' Do s.th. with the object.
End Sub