I have a piece of code that iterates through the sent items folder in Outlook and sends an email back with information regarding those sent items. However, as I am iterating through those items I need to seperate them and get a count by day. I can't seem to wrap my head around how to do this. Below is my current code. Any suggestions?
Code:
Private Sub Check_Mailbox()
Dim oNS As NameSpace
Dim oFolder As MAPIFolder
Dim strBody As String
Dim objMsg As MailItem
Dim intCount As Integer
Dim i As Integer
Dim iMeetCount As Integer
Dim dtPrevDate As Date
Dim blnDateChanged As Boolean
Set oNS = GetNamespace("MAPI")
Set oFolder = oNS.GetDefaultFolder(olFolderSentMail)
intCount = oFolder.Items.Count
Set objMsg = Application.CreateItem(olMailItem)
iMeetCount = 0
dtPrevDate = Date
For i = 1 To intCount
Select Case oFolder.Items(i).Class
Case olAppointment
'Don't do anything at this time, might need this functionality later
Case olContact
'Don't do anything at this time, might need this functionality later
Case olMail
'Don't do anything at this time, might need this functionality later
Case olMeetingRequest
dtPrevDate = oFolder.Items(i).CreationTime
strBody = strBody & "Creation Time: " & oFolder.Items(i).CreationTime & vbCrLf
strBody = strBody & "Subject: " & oFolder.Items(i).Subject & vbCrLf
strBody = strBody & "To: " & oFolder.Items(i).Recipients(1) & vbCrLf & vbCrLf
iMeetCount = iMeetCount + 1
End Select
Next
strBody = strBody & vbCrLf & "Total Items: " & iMeetCount
objMsg.To = "email address"
objMsg.Subject = "Test"
objMsg.Body = strBody
objMsg.Send
Set oNS = Nothing
Set oFolder = Nothing
Set oNewMail = Nothing
Set objMsg = Nothing
End Sub