A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Count Emails



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 8th 11, 04:20 PM
fug5333 fug5333 is offline
Junior Member
 
First recorded activity at Outlookbanter: Jan 2011
Posts: 2
Default Count Emails

I have a script:

Public Sub CountMessagesSent()
Dim Items As Outlook.Items
Dim ResultItems As Outlook.Items
Dim Filter As String
Dim DayRange As Long
Dim record As String

DayRange = -1

Set Items = Application.Session.GetDefaultFolder(olFolderSentM ail).Items

Filter = "[SentOn] = '" & DateAdd("d", DayRange, Date) & "'"

Set ResultItems = Items.Restrict(Filter)

MsgBox "Yesterday: " & ResultItems.Count

Open "C:\Users\Jeff\Desktop\Work Shortcuts\Hotkey Responses\EmailsSent.txt" For Output As #1
record = Yesterday & "," & ResultItems.Count
Print #1, record
Close #1

End Sub

Which is SUPPOSED to count only yesterdays emails, but instead I get all email sent from yesterday to current.

I am very new to VB, so any help with an explanation would be great!

Thanks!!
Ads
  #2  
Old January 9th 11, 03:04 AM
fug5333 fug5333 is offline
Junior Member
 
First recorded activity at Outlookbanter: Jan 2011
Posts: 2
Default

Anyone have an idea?
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to count # of emails in a pst? hammerhead13 Outlook - General Queries 4 July 18th 08 01:34 AM
get a count of total contacts & count in a category? Nick Chargin MBA CRS Outlook - Using Contacts 3 January 17th 08 07:40 AM
Keeping Count of emails received each day Murphybp2 Outlook and VBA 3 August 30th 07 07:17 AM
Is there a quick way to count how many emails are in my .PST file(s) ship Outlook - General Queries 3 October 30th 06 09:22 PM
Keeping Count of Emails Murphybp2 Outlook and VBA 3 August 15th 06 03:06 PM


All times are GMT +1. The time now is 05:11 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.