08-19-2010, 11:00 AM
Try to use the below code.I think this will solve your problem
Code:
Set olapp = createobject("outlook.application")
set inbox = olapp.getnamespace("mapi").folders
for each fold in inbox
msgbox fold.name
If fold.name = "Give The main Folder name" Then
getsubfolders(fold)
End If
next
msgbox inbox.count
sub getunreadmails(objfolder)
set col = objfolder.items
for each mail in col
if mail.unread then
msgbox mail.subject
msgbox mail.sendername
msgbox mail.body
msgbox mail.senton
mail.unread=false
end if
next
end sub
sub getsubfolders(objparentfolder)
set colfolders = objparentfolder.folders
for each objfolder in colfolders
set objsubfolder = objparentfolder.folders(objfolder.name)
if objfolder.name="Give the Sub Folder Name" then
getunreadmails(objfolder)
end if
getsubfolders objsubfolder
next
end sub