You just need to start your search higher up the folder tree eg.
Public Sub ProcessAllFolders()
Dim fld As MAPIFolder
For Each fld In Application.GetNamespace("MAPI").Folders
Call ProcessFolder(fld)
Next fld
End Sub
Public Sub ProcessFolder(ByRef fld As MAPIFolder)
Dim subfld As MAPIFolder
'Do Something here
For Each subfld In fld.Folders
Call ProcessFolder(subfld)
Next subfld
End Sub
--
Alan Moseley IT Consultancy
http://www.amitc.co.uk
If I have solved your problem, please click Yes below. Thanks.
"Jeremy" wrote:
Hi,
I would like to cycle through every folder in my mailbox and I have the
following code. However, i don't think this code will cycle through all
folders, I think it just cycles through those under my inbox. I don't think
the macro will cycle through folders located under .pst archives, or other
mailboxes that I have access to under my mailbox.
Is there a way a cycling through all folders, including those under other
mailboxes and archives?
My current macro is as follows:
Sub ProcessAllFolders()
ProcessSubFolder Application.ActiveExplorer.CurrentFolder
MsgBox "All Done!", vbInformation + vbOKOnly, "Process All Folders Macro"
End Sub
Sub ProcessSubFolder(olkFolder As Outlook.MAPIFolder)
Dim olkSubFolder As Outlook.MAPIFolder
'insert some code here to do something
For Each olkSubFolder In olkFolder.Folders
ProcessSubFolder olkSubFolder
Next
Set olkSubFolder = Nothing
End Sub