Retrieve Count of Emails in Outlook Subfolders

Benjamin Bolduc

Registered User.
Local time
Today, 01:10
Joined
Jan 4, 2002
Messages
169
Hi Folks,

I need to retrieve the count of emails in a shared exchange mailbox in Outlook 2010. I found the following software that retrieves the count I need, but only in default folders or ones that are 1 layer deep. The folder I need is two layers deep Mailbox -> Inbox -> Completed.

Is there anyway to drill down just one more level?

----------------------------------------
Const olFolderInbox = 6

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objInbox = objNamespace.GetDefaultFolder(olFolderInbox)

'strFolderName = objInbox.Parent
strFolderName = "benbolduc@gmail.com"

Set objMailbox = objNamespace.Folders(strFolderName)

Set objFolder = objMailbox.Folders("Inbox")

Set colItems = objFolder.Items



MsgBox objFolder.Name & " " & objFolder.Items.Count

End Sub

----------------------------------------


Any help would be greatly appreciated!
Ben Bolduc
 
I'm afraid that web site was not helpful.

Does anyone have any other suggestions? Thank you!
 
I don't have the setup on my machine nor do I have Outlook installed but there's a GetSharedDefaultFolder method in place of your GetDefaultFolder method that should do it.
 
I don't have the setup on my machine nor do I have Outlook installed but there's a GetSharedDefaultFolder method in place of your GetDefaultFolder method that should do it.

Thank you, that is encouraging to know it's possible to do what I need to do. If anyone would like to help me get there, I would be very grateful.

:)
 
try

Set objFolder = objMailbox.Folders("Inbox").Folders("Completed")
 
try

Set objFolder = objMailbox.Folders("Inbox").Folders("Completed")

Thank you so much, this worked like a charm. Please forgive me if I sounded lazy, I was very tired when I wrote this.

Works flawlessly! :)

Ben Bolduc
 

Users who are viewing this thread

Back
Top Bottom