Vba – When is a MailItem not a MailItem?


I have written a message handler function in Outlook's Visual Basic (we're using Outlook 2003 and Exchange Server) to help me sort out incoming email.

It is working for me, except sometimes the rule fails and Outlook deactivates it.

Then I turn the rule back on and manually run it on my Inbox to catch up. The rule spontaneously fails and deactivates several times a day.

I would love to fix this once and for all.

Best Answer

This code showed me the different TypeNames that were in my Inbox:

Public Sub GetTypeNamesInbox()
Dim myOlItems As Outlook.Items
Set myOlItems = application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items
Dim msg As Object

For Each msg In myOlItems
    Debug.Print TypeName(msg)
    'emails are typename MailItem
    'Meeting responses are typename MeetingItem
    'Delivery receipts are typename ReportItem
Next msg

End Sub


Related Topic