• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Print Classic Outlook Folder Names

Slipstick Systems

› Outlook › Print Classic Outlook Folder Names

Last reviewed on March 6, 2025     No Comments

I have a VBA macro that prints a list of classic Outlook folders to new message. It works great but requires the user to change macro security settings. The code on this page uses PowerShell and does not require changing macro security settings.

To use the PowerShell, you just need to paste the code into the PowerShell window. Change the file path if needed (it defaults to C:\Users\%username%\Documents.) If you want to change the sort order or include the full file paths, move the # sign in front of the lines to the other option. Then click the Run button or press F5 key.

This screenshot shows two printouts, both it just the folder names. The second one is sorted and includes the parent folder names.
Printout of classic Outlook folder list

This example shows the full file path.
Folder list with full path

Note: when you list the folders in a Microsoft Exchange account (including in Outlook.com accounts), it includes hidden folders. The code skips any folders marked with the hidden property but will trigger an error if the property does not exist on the folder. ("The property is unknown or cannot be found.") This does not affect the script. It is possible to disable error reporting in PowerShell, but it is not recommended.

 

Print a list of all folders in profile

Using the script, you can print the list of folder names in your profile (includes folders in all email accounts, in any public folders, and in PST files.)

This PowerShell creates a text file containing the list of folder names. You can include the full folder path or just the folder names and sort them alphabetically (or not). The message count is listed after the folder name.

clear 
$olApp = New-Object -comobject Outlook.Application
$namespace = $olApp.GetNameSpace("MAPI")
$Date = Get-Date -Format "yyyy-MM-dd.h-m-s"
$PropName = "http://schemas.microsoft.com/mapi/proptag/0x10F4000B"

Function Listfolders
{ 
     param($Folders, $Indent)

 #Don't sort the folder named
#ForEach ($Folder in $Folders)

#Sort folder names
  ForEach ($Folder in $Folders | sort-object name)

  {

# don't print hidden folders 
  $oPA = $Folder.PropertyAccessor
  $value = $oPA.GetProperty($PropName)
   if ($value -ne $true)
 
 {
  #path and folder name
  # echo $Indent$($Folder.FullFolderPath)" ("$($Folder.Items.Count)")" >> ~\Documents\Foldernames_$Date.txt
 
  # folder name only 
   echo $Indent$($Folder.Name)" ("$($Folder.Items.Count)")" >> ~\Documents\Foldernames_$Date.txt
   }
 
    Listfolders $Folder.Folders $Indent"  " 
  
  }
}

ListFolders $namespace.Folders ""

 

Print folders in a specific account or data file

If you have more than one email account or data file, this version of the PowerShell prints only the folders in the specific data file. You can either use the folder picker to pick the data file or enter the mailbox display name, as seen in Outlook's folder list.

Note: when using the folder picker, you can pick any folder in the data file. The script uses the root folder of the data file or mailbox in selection is in and prints all folders.
Outlook Folder Picker

clear 
$olApp = New-Object -comobject Outlook.Application
$namespace = $olApp.GetNameSpace("MAPI")

#pick data store or enter data file display name
#$datafile = $namespace.PickFolder().store

$datafile = $namespace.stores | Where-Object { $_.displayname –eq ‘alias@domain.com’}
$mailbox = $datafile.GetRootFolder()

#used in text file name
$Date = Get-Date -Format "yyyy-MM-dd.h-m-s"
$PropName = "http://schemas.microsoft.com/mapi/proptag/0x10F4000B"

Function Listfolders
{ 
     param($Folders, $Indent)

 #Don't sort the folder named
 ForEach ($Folder in $Folders)

#Sort folder names alphabetically
#ForEach ($Folder in $Folders | sort-object name)

  {
  $oPA = $Folder.PropertyAccessor
  $value = $oPA.GetProperty($PropName)
   if ($value -ne $true)
   {

  #mailbox name and full folder path indented
  #write to text file
  echo $Indent$($Folder.FullFolderPath)" ("$($Folder.Items.Count)")"  >> ~\Documents\Foldernames_$Date.txt

#folder name only, indented
 #write to text file
 #echo $Indent$($Folder.Name)" ("$($Folder.Items.Count)")" >> ~\Documents\Foldernames_$Date.txt

    Listfolders $Folder.Folders $Indent"  " 
  }
}
}

ListFolders $mailbox.Folders ""

 

Using PowerShell Scripts

To use PowerShell scripts with Outlook, start typing PowerShell on the start menu and open Windows PowerShell when it comes up. Windows PowerShell ISE has a script pane at the top, which is useful if you want to edit the script. (Click the icon on the right to show or hide the script window or the Window button in the toolbar.)

Paste the entire script in the PowerShell window and press Enter or the Run button. This screenshot is of PowerShell ISE.

PowerShell ISE

Note: PowerShell scripts will not work with new Outlook or Outlook on the web.

Saving PowerShell Scripts

If you want to save the script as a .ps1 file, paste it into Notepad and save it with the extension .ps1. To open it in the PowerShell IDE, type PowerShell on the start menu and click on Windows PowerShell IDE when the PowerShell app is found. Paste the script in the editing window.

To use it, you need to allow local scripts by running this command:

Set-ExecutionPolicy RemoteSigned

To run your saved .ps1 file, right-click on the script and choose Run with PowerShell.

Print Classic Outlook Folder Names was last modified: March 6th, 2025 by Diane Poremsky

Related Posts:

  • Delete Empty Folders using PowerShell
  • Create new Outlook folders using PowerShell
  • Print a list of your Outlook folders
  • Open Outlook Folders using PowerShell or VBScript

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Subscribe
Notify of
0 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 30 Issue 15

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Use Classic Outlook, not New Outlook
  • How to Remove the Primary Account from Outlook
  • Disable "Always ask before opening" Dialog
  • Adjusting Outlook's Zoom Setting in Email
  • This operation has been cancelled due to restrictions
  • Remove a password from an Outlook *.pst File
  • Reset the New Outlook Profile
  • Maximum number of Exchange accounts in an Outlook profile
  • Save Attachments to the Hard Drive
  • How to Hide or Delete Outlook's Default Folders
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
  • New Outlook: Show To, CC, BCC in Replies
  • Insert Word Document into Email using VBA
  • Delete Empty Folders using PowerShell
  • Warn Before Deleting a Contact
  • Classic Outlook is NOT Going Away in 2026
  • Use PowerShell to Delete Attachments
  • Remove RE:, FWD:, and Other Prefixes from Subject Line
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

New Outlook: Show To, CC, BCC in Replies

Insert Word Document into Email using VBA

Delete Empty Folders using PowerShell

Warn Before Deleting a Contact

Classic Outlook is NOT Going Away in 2026

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Newest Code Samples

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

Use PowerShell or VBA to get Outlook folder creation date

Rename Outlook Attachments

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2025 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment