Mailbox Counter

G

Guest

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.
 
G

Guest

Hello Tom,
I think you need to first create the object Wscript.
Or try to write WScript instead of Wscript. (S should be capital)
Not sure if that's the reason for it, but the JavaScript error should be
coming from there.


Regards,
nana
 

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