PDA

View Full Version : referencing a sub folder



OTWarrior
02-06-2009, 05:08 AM
I understand how to reference the currently selected folder using:

Function DisplayCurrentFolderName()
Dim myOlApp As Outlook.Application
Dim myExplorer As Outlook.Explorer
Dim myFolder As Outlook.MAPIFolder
Set myOlApp = CreateObject("Outlook.Application")
Set myExplorer = myOlApp.ActiveExplorer
Set myFolder = myExplorer.CurrentFolder

DisplayCurrentFolderName = myFolder.Name

End Function


This will display the name of the folder or sub folder that is selected, however I am unsure how to reference a sub folder without selecting it and running this function.

I know you can loop through the default parent folders (inbox, outbox), but how do you do this with subfolders?

jfournier
02-06-2009, 07:33 AM
The MAPIFolder class has a Folders class which is named Folders, which is basically just a collection of the folders' subfolders.

Fox example:

Dim myFolder as MAPIFolder
set myFolder = ...
Dim CurrSubFolder as MAPIFolder
For each CurrSubFolder in myFolder
' Do whatever
Next CurrSubFolder