Thread: Mailbox Counter
View Single Post
  #1  
Old May 2nd 07, 04:06 PM posted to microsoft.public.outlook.program_vba
CMPTom
external usenet poster
 
Posts: 1
Default Mailbox Counter

Good Afternoon all,

I'm trying to acquire a VBA script for use in a macro that would be able to
tell me how many emails my account is recieving each day. I work in a busy
sales office, whereby 5/6 people all have access to this account. I've found
a code that could be useful through an affliated Microsoft site which i have
pasted underneath:

"Sub MailCounter()

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

End Sub"

However, when i attempt to run this, i get an 'Error 424: Object required'
message and it prompts me to look at the "Wscript.echo strKey,
objDictionary.Item(strKey)" piece of code.

Can anyone help with this please? either with the code i already have or
with an entirely different piece.

It's to be used within a Macro, so at the end of the day - any number of
people can activate it to get a reading of emails recieved for the day.

Thanks
Tom Clarkin
CMP Batteries, Bolton, UK.
Ads