Gord
thanks heaps for this - I have included the code (minus your code) for you -
have tried your suggestion but am obviously doing something wrong with
editing code to 'put' value in msg box in cell d1.
Again many thanks to those who have helped with this (includes those from
other posts)
shaz
Sub HowManyDatedEmails_S()
Dim objOutlook As Object, objnSpace As Object, objFolder As Object
Dim EmailCount As Long
Set objOutlook = CreateObject("Outlook.Application")
Set objnSpace = objOutlook.GetNamespace("MAPI")
On Error Resume Next
Set objFolder = objnSpace.Folders("Mailbox - Sharon
Hickox").Folders("Personal")
If Err.Number <> 0 Then
Err.Clear
MsgBox "No such folder."
Exit Sub
End If
Dim iCount As Integer
Dim DateCount As Integer
Dim myFirstDate As Date
Dim myLastDate As Date
EmailCount = objFolder.Items.Count
DateCount = 0
myFirstDate = Sheets("Sheet1").Range("A1").Value
myLastDate = Sheets("Sheet1").Range("A2").Value
For iCount = 1 To EmailCount
With objFolder.Items(iCount)
If DateSerial(Year(.ReceivedTime), _
Month(.ReceivedTime), _
Day(.ReceivedTime)) >= myFirstDate And _
DateSerial(Year(.ReceivedTime), _
Month(.ReceivedTime), _
Day(.ReceivedTime)) <= myLastDate Then
DateCount = DateCount + 1
End If
End With
Next iCount
Set objFolder = Nothing
Set objnSpace = Nothing
Set objOutlook = Nothing
MsgBox "Number of emails in Personal folder with matching date: " &
DateCount, , "Personal date count"
End Sub