Get outlook mail message in all folders and subfolders


I want to retrieve any email containing a filter on the subject of an email, however I am required to specify a folder in the “MailFolder” entry.

The script will be used on multiple mailboxes, and I don’t know in advance the folders and subfolders present in this mailbox.

Can you tell me how to do that?

Thank you in advance.

If you use an In Argument as the name of your MailFolder you can specify which folder should be used each time you run the process.


1 Like

Thank you for your answer, however I am trying to search all the folders in the outlook box without having to specify which ones because each outlook account has different folders whose names I do not have.

If you need to dynamically get folder names you’ll probably need to write something custom using the Outlook Interop library.

Or you could open Outlook and scrape all of the folder names once it is opened.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.