A G
asked on
How to modify the code so it checks the subfolders as well
I found the following code on the net. I ran this and I realize that it is looking to the folders under mailbox. But not looking to the subfolders like "Inbox". I want to be able to check subfolders too, specifically the ones under Inbox. How would I modify this code so it will look for the subfolders as well.
thanks
thanks
Dim myolApp As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim found As Boolean
Dim strFolderName As String
'specify the folder you are looking for
strFolderName = "Inbox"
found = False
Set myolApp = GetObject(, "Outlook.Application")
Set myNameSpace = myolApp.GetNamespace("MAPI")
For i = 1 To (myNameSpace.Folders.Count)
For j = 1 To (myNameSpace.Folders(i).Folders.Count)
' MsgBox myNameSpace.Folders(i).Folders(j).Name
If myNameSpace.Folders(i).Folders(j) = strFolderName Then
Set Application.ActiveExplorer.CurrentFolder = _
myNameSpace.Folders(i).Folders(j)
Exit For
End If
Next
If found = True Then Exit For
Next
If found = True Then MsgBox "Rune Lange Sen Bir ibnesin"
Set myolApp = Nothing
Set myNameSpace = Nothing
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.freevbcode.com/ShowCode.Asp?ID=1064