Outlook Message Count - VBA Error - Multiple Inboxes

R

Ryan

I am trying to get a count of how many messages per date I have in my
generic inboxes. I have multiple inboxes I manage and need to count the
messages by day. This code work for MY inbox only, not the generic inboxes.
Any help? Thanks!!

Const olFolderInbox = 6

Set objDictionary = CreateObject("Scripting.Dictionary")

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

Set colItems = objFolder.Items

For Each objItem in colItems
strDate = FormatDateTime(objItem.SentOn, vbShortDate)
If objDictionary.Exists(strDate) Then
objDictionary.Item(strDate) = objDictionary.Item(strDate) + 1
Else
objDictionary.Add strDate, "1"
End If
Next

colKeys = objDictionary.Keys

For Each strKey in colKeys
Wscript.Echo strKey, objDictionary.Item(strKey)
Next
 
S

Sue Mosher [MVP-Outlook]

YOu can use the Namespace.GetSharedDefaultFolder method to return the Inbox folder from other mailboxes where you have permission.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Thanks for the help Sue -- I'm sorry that I don't quite understand though,
how would the coding look? I'm an extreme newbie to this! Do I need the
name of the actual inbox I'm trying to access?
 
S

Sue Mosher [MVP-Outlook]

What you need is the name of the *mailbox*, i.e. the user whose mailbox you want to access. The Help topic on GetSharedDefaultFolder has a complete example of the syntax.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top