I have a program that goes through an Outlook folder and counts all of the email items in that folder and seperates it by date. However, I am running into type mismatch error if the program runs across a meeting request or any other object in the folder that's not a mail item. I tried using the CType function to compare the objects, but I wasn't able to get it to work (guessing it's not supported in VBA?). Any ideas for how to compare each item in the folder and determine if it's an email item, and if not disregard it?
Code:
For Each x In objFolder.Items
Set objEmails(i) = x
tmpDate = DateValue(objEmails(i).ReceivedTime)
intDay = Day(tmpDate)
If intDay >= 1 And intDay <= 31 Then
If g_intMonth = Month(objEmails(i).ReceivedTime) And
g_intYear = Year(objEmails(i).ReceivedTime) Then
intCount(intDay) = intCount(intDay) + 1
End If
End If
Next