Get Outlook Mail Folders and Sub-Folders List

Hi All,

  I am working on a Outlook Email Automation Process and I have a requirement to get the list of all the folders and sub folders like "Inbox, Sent Items, Drafts etc." available in the Outlook Mail. Further, getting details of each mail in the particular folder.
  I have completed the second part and is facing problem in getting the list of mail folders available.

  If anyone has worked on similar UseCase, kindly help.

Gauri Walzade


Sorry. We don’t have any direct activity to fetch the all folder names from outlook. If you want to read mails from particular folder or subfolder then simply specify that path in Get Outlook MailMessage activity and retrieve mails.

Here we go using Invoke VBA option. Try it and let me know. You can write VBA code to insert the output to excel. Here used just Messagebox. Also to further enhance as per your requirement try writing the same in excel VBA code :slight_smile:

Use - Invoke Code( Workflow- Invoke- Invoke Code)

Dim olApp As Microsoft.Office.Interop.Outlook.Application
Dim olNs As Microsoft.Office.Interop.Outlook.Namespace
Dim olParentFolder As Microsoft.Office.Interop.Outlook.MAPIFolder
Dim olFolderA As Microsoft.Office.Interop.Outlook.MAPIFolder
Dim olFolderB As Microsoft.Office.Interop.Outlook.MAPIFolder
olApp = New Microsoft.Office.Interop.Outlook.Application
olNs = olApp.GetNamespace(“MAPI”)
olParentFolder = olNs.Folders("").Folders(“Inbox”)
For Each olFolderA In olParentFolder.Folders
'Msgbox(olFolderA.FolderPath, olFolderA.Items.Count, olFolderA.Folders.Count)
For Each olFolderB In olFolderA.Folders
'Msgbox(olFolderB.FolderPath, olFolderB.Items.Count)

1 Like

Thanks. Will surely try.

Thanks:):slight_smile: Working good!!!

1 Like