Question Locked

Print a List of all my Outlook Folders and Sub-Folders

0 helpful
8 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello, how would I print a list of all my Outlook 2007 mail folders and sub-folders. I have an extensive list of personal folders and sub-folders and I would like to be able to print them. Any ideas?

Thanks.

Cadonn

8 replies

by dan.cox

Try this vbscript.
It is from the Microsoft Scripting Guys.
Great resource.

Const olFolderInbox = 6

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")

Set objInbox = objNamespace.GetDefaultFolder(olFolderInbox)

Wscript.Echo objInbox.Name

GetSubfolders(objInbox)

Sub GetSubfolders(objParentFolder)
Set colFolders = objParentFolder.Folders
For Each objFolder in colFolders
Set objSubfolder = objParentFolder.Folders(objFolder.Name)
Wscript.Echo objFolder.Name
GetSubfolders objSubfolder
Next
End Sub

by cadonn

Thank you so much I will give this a try and report back.

Again, many thanks.

Cadonn

by cadonn

Hi, I tried to run the script and have received an error message Microsoft Visual Basic, Complile Error: Invalid outside procedure with SET highlighted on the first line
Set objOutlook = CreateObject("Outlook.Application")

What am I doing wrong? I did this within outlook. Do I have to add Sub in front of the first line before Const? Sorry I am really new at all of this. Thank you.

Cathy

by cadonn

Hi, that is what I did. When I double-click to run the script a Windows Script Host dialogue box appears with the words: Inbox OK. Since I am really new at this - I am not sure where to look for the results of the script?

Thank you.

Cadonn

by hsnzz

I found some responses on different website but since they didn't fully work, I ended up patching some examples together to create the below vsb script which allows you to select any folder or archive in Outlook and then list out its subfolders to a text file.
Hope it helps, thanks Hasan.

dim loggit_logfilename, loggit_fso, loggit_silent

loggit_logfilename = ".\Outlook_Folder_List.log"
loggit_silent = true ' log file only or with MsgBox/Echo
set loggit_fso = CreateObject("Scripting.FileSystemObject")

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")

Set olFolder = objNamespace.PickFolder
loggit "Selected Archive Name: " & olFolder.Name
loggit "Total Number of Sub Folders: " & olFolder.Folders.Count

GetSubfolders(olFolder)

Sub GetSubfolders(objParentFolder)
Set colFolders = objParentFolder.Folders
For Each objFolder in colFolders
Set objSubfolder = objParentFolder.Folders(objFolder.Name)
loggit objFolder.FolderPath
GetSubfolders objSubfolder
Next
End Sub

Wscript.Echo "Done. Log file created/appended at " & loggit_fso.GetParentFolderName(wscript.ScriptFullName) & "\Outlook_folder_list.org"

' From http://www.rgagnon.com/wshdetails/wsh-0003.html -=-=-=-=-=-=-=-=-=-
sub loggit (msg)
set stream = loggit_fso.OpenTextFile(loggit_logfilename, 8, True)
stream.writeline date & " " & time & ": " & msg
stream.close
if not loggit_silent then
WScript.echo msg
end if
end sub

This discussion is closed to new replies.