Outlook Windows Download Mailbox Folders Thumbnail

Download Outlook Mailbox Folder List

When revamping an Outlook Mailbox, a printable list of all folders and subfolders will be useful. Here are the steps to download the list of folders in a new email message using a VBA script.  

Microsoft’s Visual Basic for Application (VBA) is a fancy name for running a macro. Do not get intimidated by this VBA script.  All you need to do is copy and paste the code which I have provided below. Next, run the script. It is easy to do. 

If this is your first time working with a VBS Script, you can watch the video for additional comfort.

Download a list of Outlook Mail folders and subfolders

  • Navigate to Outlook Windows (Desktop)
  • To open the VBA Editor, click on Alt + F11
  • In the left navigation, right-click on Project1
  • Click on Insert, then Module
Navigate to VBA for Outlook Windows Download Mailbox Folders
  • Copy the code below and paste it into the Module.
    Note: The image is what it will look like after pasting the code in the module.
Outlook Windows Download Mailbox Folders Code

VBA Script Code for a list of Outlook Mailbox Folders

Here is the code to copy by pressing Ctrl + C. You must ensure that you highlight and copy all the code lines or it will not work properly. 

Revised code as of February 4, 2024. Thanks DJ.

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

Run the VBA Script

There are three options to open the run console before running the script.

Method 1: Press F5

Method 2: Click on the Play icon located in the top menu

VBA Run Play Icon


Method 3:
From the top menu, click on Run then Run Sub/UserForm

VBA Script Run Menu
  • Click on the macro name, GetFolderNames, then press Run
Macro for Outlook Windows Download Mailbox Folders
  • Now, you can choose which exchange mailbox (the icon with the E) you want to run the script on and press Ok.
  • Note: For privacy purposes, the email addresses are removed from the image below.

Select Mailbox Outlook Windows Download Mailbox Folders

New Email Message with a list of Outlook Folders

  • Allow time for the macro to run if you have a lot of folders. The list of folders and subfolders is added in a new email message. The user’s email address will appear in the From line and the email body with the folder and subfolder location structure.
  • In the image below, I blurred out the email address for privacy purposes.
Email with Outlook Windows Download Mailbox Folders

Additional Resources

For additional help with revamping an Outlook Mailbox, the blog post, All Outlook Contact Fields, provides a list of contact fields in the desktop and online applications. 

Outlook Contact Fields

Leave a Comment

Your email address will not be published. Required fields are marked *