H
Hans-Christian Francke
How do I enumerate all the folders located under my Pernonal Folders.
Thank for any hints.
Thank for any hints.
Ken Slovak - said:Here's a sample of some code I've used to set the default form for all
Contacts folders in an InfoStore. It first gets the default Contacts
folder, then its parent folder which is the TopOfInformationStore
(shown in the UI as Mailbox - xxx or Personal Folders). You can modify
this code to recursively iterate the entire collection of folders.
Public Sub SetForm()
Dim oFolder As Outlook.MAPIFolder
Dim oParent As Outlook.MAPIFolder
On Error Resume Next
blnPublished = False
Set oFolder = g_objNS.GetDefaultFolder(olFolderContacts)
Set oParent = oFolder.Parent
Call SetAllContactFolders(oParent)
Set oFolder = Nothing
Set oParent = Nothing
End Sub
Private Sub SetAllContactFolders(oSourceFolder As Outlook.MAPIFolder)
Dim oFolder As Outlook.MAPIFolder
Dim colFolders As Outlook.Folders
On Error Resume Next
Set colFolders = oSourceFolder.Folders
If Not (colFolders Is Nothing) Then
For Each oFolder In colFolders
If oFolder.DefaultItemType = olContactItem Then
'do whatever
End If
'recursive call to SetAllContactFolders.
'repeat until no more subfolders
Call SetAllContactFolders(oFolder)
Next
End If
Set oFolder = Nothing
Set colFolders = Nothing
End Sub