General discussion

Locked

VBA code to display folders hierarchy in

By Zalog ·
Could someone show me the source code for displaying a hierarchy tree of folders in Outlook 2000. I'm not looking for anything fancy just to get a list of folders to the debug window. Something like:
Mailbox - user
Calendar
Contacts
...
Public Folders
...

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

VBA code to display folders hierarchy in

by zalo9 In reply to VBA code to display folde ...

Option Explicit

Private Sub CommandButton1_Click()
Dim golApp As Outlook.Application
Dim gnspNameSpace As Outlook.NameSpace
Dim myfolder As Outlook.MAPIFolder
Dim newFolder As Outlook.MAPIFolder
Dim j As Integer

Set golApp = New Outlook.Application ' Application object.
Set gnspNameSpace = golApp.GetNamespace("MAPI") ' Namespace object.

With gnspNameSpace.Folders
Set myfolder = .GetFirst
Call GetFolderNames(myfolder, 0)
For j = 2 To .Count
Set newFolder = .GetNext
Call GetFolderNames(newFolder, 0)
Next
End With
End Sub

Sub GetFolderNames(fldFolder As Outlook.MAPIFolder, level As Integer)Dim objItem As Object
Dim iTab As Integer

On Error Resume Next
For iTab = 1 To level
Debug.Print " ";
Next iTab
Debug.Print fldFolder.Name & " (" _
& fldFolder.Items.Count & " items)"
If fldFolder.F

Collapse -

VBA code to display folders hierarchy in

by Zalog In reply to VBA code to display folde ...
Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums