Skip to content

Instantly share code, notes, and snippets.

@guinslym
Created August 21, 2018 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guinslym/d1c4d6f4568a52d25eafa1933e6f2825 to your computer and use it in GitHub Desktop.
Save guinslym/d1c4d6f4568a52d25eafa1933e6f2825 to your computer and use it in GitHub Desktop.
Sub List_All_NameSpace_Folders()
'https://stackoverflow.com/questions/16225353/outlook-macro-to-collect-extract-data-from-subject-field-of-numerous-messages
Dim myNS As NameSpace
Dim myFolder As MAPIFolder
Dim mySubfolder As MAPIFolder
Dim strFolderList As String
strFolderList = "Your Outlook NameSpace contains these folders:" _
& vbCr & vbCr
Set myNS = Application.GetNamespace("MAPI")
With myNS
For Each myFolder In myNS.Folders
strFolderList = strFolderList & myFolder.Name & vbCr
For Each mySubfolder In myFolder.Folders
strFolderList = strFolderList & "* " & mySubfolder.Name & vbCr
Next mySubfolder
Next myFolder
End With
MsgBox strFolderList, vbOKOnly + vbInformation, "Folders in NameSpace"
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment