Skip to main content

How to export and print list of all folders and subfolders in Outlook?

Author Kelly Last modified

Generally speaking, you can press "Ctrl" + "6" keys to view the list of all folders on the Navigation Pane in Outlook. However, you cannot print the list of folders directly. This article introduces two VBA scripts to export and print the list of all folders and their subfolders in Outlook.


Export and print the list of all Outlook folders and their subfolders in new email

This method introduces a VBA script to export the list of all folders and their subfolders in a specified email account into a new email in Outlook. Then, you can easily print the folder list.

1. Press "Alt" + "F11" to open the Microsoft Visual Basic for Applications window.

2. Click "Insert" > "Module", and paste the following VBA code into the new module window.

VBA: Export the list of folders and subfolders in a new email in Outlook

Public gFolders As String

Public Sub GetFolderNames()
Dim oSession As Outlook.NameSpace
Dim oFolder As Outlook.MAPIFolder
Dim oNewMail As Outlook.MailItem

Set oSession = Outlook.Application.GetNamespace("MAPI")
Set oFolder = oSession.PickFolder

If (oFolder Is Nothing) Then Exit Sub

ProcessFolder oFolder

Set oNewMail = Application.CreateItem(olMailItem)
oNewMail.Body = gFolders
oNewMail.Display

gFolders = ""
End Sub

Sub ProcessFolder(CurrentFolder As Outlook.MAPIFolder)
Dim i As Long
Dim oSubFolder As Outlook.MAPIFolder
Dim oFolder As Outlook.MAPIFolder
Dim sFolderPaths As String

For i = CurrentFolder.Folders.Count To 1 Step -1
    Set oFolder = CurrentFolder.Folders(i)
    sFolderPaths = oFolder.FolderPath
    gFolders = gFolders & vbCrLf & sFolderPaths & " " & oFolder.Items.Count
Next

For Each oSubFolder In CurrentFolder.Folders
    If oSubFolder.Name <> "Deleted Items" Then
        ProcessFolder oSubFolder
    End If
Next
End Sub

3. Press "F5" to run the VBA.

4. In the popping out Select Folder dialog box, select the email account whose folder list you want to print, and click "OK".

Select folder dialog

5. The folder list of the selected account will be copied to a new email as shown below. Click "File" > "Print" to print the folder list.

Generated email with folder list

6. After printing, close the new email without saving.


Export and print the list of all Outlook folders and their subfolders in Notepad

This method introduces a VBA script to export the list of all folders and their subfolders in a specified email account from Outlook to Notepad. You can then easily print the folder list.

1. Press "Alt" + "F11" to open the Microsoft Visual Basic for Applications window.

2. Click "Insert" > "Module", and then paste the following VBA code into the new module window.

VBA: Export the list of all Outlook folders and subfolders from Outlook to Notepad

Dim gFileName, gCreateTree, gBase

Public Sub ExportFolderTree()
Dim objOutlook
Dim F, Folders
Dim Result

Set objOutlook = CreateObject("Outlook.Application")
Set F = objOutlook.Session.PickFolder

If Not F Is Nothing Then
    Set Folders = F.Folders
    Result = MsgBox("Do you want to create tree?", vbYesNo + vbDefaultButton2 + vbApplicationModal, "Output Folder Tree")
    If Result = 6 Then
        gCreateTree = True
    Else
        gCreateTree = False
    End If

    gFileName = GetDesktopFolder() & "\Outlook-Folders.txt"
    gBase = Len(F.FolderPath) - Len(Replace(F.FolderPath, "\", "")) + 1

    WriteToATextFile (CreateFolderTree(F.FolderPath, F.Name))
    LoopFolders Folders

    Set F = Nothing
    Set Folders = Nothing
    Set objOutlook = Nothing
End If
End Sub

Private Function GetDesktopFolder()
Dim objShell
Set objShell = CreateObject("WScript.Shell")
GetDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShell = Nothing
End Function

Private Sub LoopFolders(Folders)
Dim F
For Each F In Folders
    WriteToATextFile (CreateFolderTree(F.FolderPath, F.Name))
    LoopFolders F.Folders
Next
End Sub

Private Sub WriteToATextFile(OLKfoldername)
Dim objFSO, objTextFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(gFileName, 8, True)
objTextFile.WriteLine (OLKfoldername)
objTextFile.Close
Set objFSO = Nothing
Set objTextFile = Nothing
End Sub

Private Function CreateFolderTree(OLKfolderpath, OLKfoldername)
If gCreateTree = False Then
    CreateFolderTree = Mid(OLKfolderpath, 3)
Else
    Dim i, x, OLKprefix
    i = Len(OLKfolderpath) - Len(Replace(OLKfolderpath, "\", ""))
    For x = gBase To i
        OLKprefix = OLKprefix & "-"
    Next
    CreateFolderTree = OLKprefix & OLKfoldername
End If
End Function

3. Press "F5" to run the VBA. In the opening Select Folder dialog box, select the email account whose folder list you want to export and print, then click "OK".

Select folder dialog

4. The Output Folder Tree dialog box will appear. Click "Yes" or "No" depending on whether you want to include tree indentation.

Prompt for tree creation

Now, a text file named "Outlook-Folders" is created and saved on your desktop as shown below:

Outlook-Folders text file

5. Double-click to open the new text file, then click "File" > "Print" to print the exported list of Outlook folders.

AI Mail Assistant in Outlook: Smarter Replies, Clearer Communication (one-click magic!) FREE

Streamline your daily Outlook tasks with the AI Mail Assistant from Kutools for Outlook. This powerful tool learns from your past emails to offer intelligent and accurate responses, optimize your email content, and help you draft and refine messages effortlessly.
doc ai email handle

This feature supports:

  • Smart Replies: Get responses crafted from your past conversations—tailored, precise, and ready to go.
  • Enhanced Content: Automatically refine your email text for clarity and impact.
  • Effortless Composition: Just provide keywords, and let AI handle the rest, with multiple writing styles.
  • Intelligent Extensions: Expand your thoughts with context-aware suggestions.
  • Summarization: Get concise overviews of long emails instantly.
  • Global Reach: Translate your emails into any language with ease.

This feature supports:

  • Smart email replies
  • Optimized content
  • Keyword-based drafts
  • Intelligent content extension
  • Email summarization
  • Multi-language translation

Best of all, this feature is completely free forever! Don’t wait—download AI Mail Assistant now and enjoy!

Related Articles

Show or hide folder list view in Outlook


Best Office Productivity Tools

Breaking News: Kutools for Outlook Launches Free Version!

Experience the all-new Kutools for Outlook with 100+ incredible features! Click to download now!

🤖 Kutools AI : Uses advanced AI technology to handle emails effortlessly, including replying, summarizing, optimizing, extending, translating, and composing emails.

📧 Email Automation: Auto Reply (Available for POP and IMAP)  /  Schedule Send Emails  /  Auto CC/BCC by Rules When Sending Email  /  Auto Forward (Advanced Rules)   /  Auto Add Greeting   /  Automatically Split Multi-Recipient Emails into Individual Messages ...

📨 Email Management: Recall Emails  /  Block Scam Emails by Subjects and Others  /  Delete Duplicate Emails  /  Advanced Search  /  Consolidate Folders ...

📁 Attachments ProBatch Save  /  Batch Detach  /  Batch Compress  /  Auto Save   /  Auto Detach  /  Auto Compress ...

🌟 Interface Magic: 😊More Pretty and Cool Emojis   /  Remind you when important emails come  /  Minimize Outlook Instead of Closing ...

👍 One-click Wonders: Reply All with Attachments  /   Anti-Phishing Emails  /  🕘Show Sender's Time Zone ...

👩🏼‍🤝‍👩🏻 Contacts & Calendar: Batch Add Contacts From Selected Emails  /  Split a Contact Group to Individual Groups  /  Remove Birthday Reminders ...

Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Instantly unlock Kutools for Outlook with a single click. Don't wait, download now and boost your efficiency!

kutools for outlook features1 kutools for outlook features2