![]() |
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. |
Mailbox Counter
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 "CMPTom" wrote: 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. |
All times are GMT +1. The time now is 07:04 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com