Questions

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

+
1 Votes
Locked

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

cadonn
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
  • +
    0 Votes
    IC-IT

    It works in Outlook 2003 and may still work for 2007. Scroll down to the end of the thread. Copy and paste into a text editor and save as a vbs file.

    http://www.ozgrid.com/forum/showthread.php?t=76159

    +
    0 Votes
    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

    +
    0 Votes
    cadonn

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

    Again, many thanks.

    Cadonn

    +
    0 Votes
    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

    +
    0 Votes

    ?

    dan.cox

    What do you mean you did this within outlook?

    Open Notepad and create a new file with the extension .vbs. This is where the script goes.
    Double click your script file to run it.
    Try that.

    Read this link. It may help.

    http://www.microsoft.com/technet/scriptcenter/resources/qanda/jun06/hey0616.mspx

    +
    0 Votes
    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

    +
    0 Votes
    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

  • +
    0 Votes
    IC-IT

    It works in Outlook 2003 and may still work for 2007. Scroll down to the end of the thread. Copy and paste into a text editor and save as a vbs file.

    http://www.ozgrid.com/forum/showthread.php?t=76159

    +
    0 Votes
    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

    +
    0 Votes
    cadonn

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

    Again, many thanks.

    Cadonn

    +
    0 Votes
    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

    +
    0 Votes

    ?

    dan.cox

    What do you mean you did this within outlook?

    Open Notepad and create a new file with the extension .vbs. This is where the script goes.
    Double click your script file to run it.
    Try that.

    Read this link. It may help.

    http://www.microsoft.com/technet/scriptcenter/resources/qanda/jun06/hey0616.mspx

    +
    0 Votes
    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

    +
    0 Votes
    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