Outlook VBA: Iterate recursively over folders

Note: This is a post transferred from Laurii for historical and consolidation purposes.

As part of the program I’ve started, I had to perform a recursive walking of all sub-folders from a starting point in a .pst file. Code looks like this:

This doesn’t do too much… It selects a folder and calls a function. The recursive part is below:

Now, you can process each item in the directory in the first loop and elegantly call a per-item processor (d’oh!). Other than that, VBA in Outlook 2003 is not nice… The tiniest mistake, you get an error. It doesn’t like something (like strings and objects), you get an error. Not nice after processing 100 emails to get something like Mismatched objects… Still, it’s quicker than doing a C# :(

A little experiment: If you find this post and ad below useful, please check the ad out :-)

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to top