List all folders in a Microsoft Outlook account

Recently, I wanted to create a list of all the folders in my MS Outlook PST file together with the size of each folder. Outlook provides that information through the user interface. Unfortunately, it shows the result in a modal dialog with no way to save the information elsewhere. So, I decided to check if I could find some ready-to-use (or nearly ready-to-use) code that did the needful. A search of the web led to several ideas and suggestions but no code to do the needful. So, I decided to put together a VBA module that would save the information in an Excel worksheet.

For a version in a page by itself (i.e., not in a scrollable iframe as below) visit http://www.tushar-mehta.com/publish_train/xl_vba_cases/1201%20Outlook%20folder%20info.shtml

Tushar Mehta

5 Comments

  1. Hi,
    Thanks for the tip. My mail is on a server, with archives & public folders etc.

    I gave up waiting for the macro to run when I realised it was looping through everything!

    I then replaced:

    For Each aFolder In NS.Folders

    getAFolderInfo 0, aFolder, Rslt, AllGroups

    Next aFolder

    with

    For Each aFolder In NS.Folders

    debug.print aFolder.name
    Next aFolder

    to get a list of the top level folders, one of which was my account: firstname.surname@domain.com

    I then used an if statement to restrict your original recursive loop to that account & it worked like a dream.

    Thank you, I’ve always hated the way MS wouldn’t give you this info in any sort of useful format!

    M

  2. This is a nice piece of code, but i do not want the public folders to be listed in the sheet, request to provide a way out for its operation.

    In the above mentioned code in consolidating in public folders the code gets stuck up at the point saying, “Exchange Server is busy, please try again in 30 minutes”.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>