In this post I published 100 lines of code that showed how to get a visual representation of your hard disk to see which folders take the most space. It showed that my Outlook mailbox was half a gigabyte. (“C:\DOCUMENTS AND SETTINGS\CALVINH\LOCAL SETTINGS\APPLICATION DATA\MICROSOFT\OUTLOOK” ). I am using some great features of Outlook: Cached Exchange Mode which makes my entire mailbox available offline and RPC over HTTP which allows me to use Outlook over an internet connection without logging onto the network at work. I just knew cached mode used a lot of space!
Well it was really simple to add another method onto the class to map my Outlook Mailbox visually to see what was taking the most space within that half gigabyte. The rest of the code just works as expected: Tooltips show the folder name and size, and you can click on a rectangle to drill down into the tree.
As an exercise, you could even modify the code so that if you navigate through your hard disk folders to the Outlook folder on your hard disk, it seamlessly just drills down into your mailbox inside.
Use this line to create the form. Here, I’m using “*” to represent an Outlook 2003 mailbox. Be sure to change the mailbox name. Note it uses GETOBJECT function which assumes Outlook is already running.
In the INIT method, Replace the this.DoDir(cPath) line with
loApp = GETOBJECT("","Outlook.application")
And then add this method
PROCEDURE DoOutlook(cPath as String, nDepth as Integer, oFolder as Outlook.MAPIFolder) as Number && Recursive routine to get folders and their sizes
LOCAL oSubfolder as Outlook.MAPIFolder,oItem as Outlook.MailItem
LOCAL nTotal, nFileTotal
FOR EACH oSubfolder as Outlook.MAPIFolder IN oFolder.Folders
FOR EACH oItem as Outlook.MailItem IN oFolder.Items
INSERT INTO dirs (Path,Depth,size) VALUES (cPath+'\',nDepth,nTotal) && insert the total subfolder info
INSERT INTO dirs (Path,Depth,size) VALUES (cPath+"*\",nDepth+1,nFileTotal) && for items within current folder