Appointment/Meeting Invites using VBA

In addition to handling Emails, MS Outlook application also handles calendar appointments & meeting invites.

All these items are received in your Inbox. We could identify the difference manually by seeing the icon for each item.

But to identify the difference in a VBA code, we can use one of these 2 techniques.

  1. TypeName
  2. MessageClass

Here is a VBA code that will select only the Appointment items from Inbox.

Sub FilterAppointmentMeetingInvitesVBA()
    'Code from Officetricks
    'Define DataType for Outlook Related Variable fields
    Dim objNameSpace As Outlook.NameSpace
    Dim objInbox As Outlook.Folder
    Dim ObjMailBox As Outlook.MAPIFolder
    Dim objMailItem
        
    'Initialize Fields
    Set objNameSpace = Outlook.Application.GetNamespace("MAPI")
    Set ObjMailBox = objNameSpace.Folders("<MailboxName@domain.com>") 'Type your mailbox name
    Set objInbox = ObjMailBox.Folders("Inbox")
    
    For Each objMailItem In objInbox.Items

        Debug.Print objMailItem.MessageClass & " - " & objMailItem.Subject
        'Method1
        If TypeName(objMailItem) = "MeetingItem" Then
            'Only Appoinment/Meetings are selected
        End If
        
        'Method2
        If objMailItem.MessageClass = "IPM.Schedule.Meeting.Request" Then
            'Only Appoinment/Meetings are selected
        End If
    Next
End Sub

This code will be able to differentiate between a mail item & a meeting invite.

You can use one of these methods. In some older version of Ms Outlook the appointment will not be detected as “MeetingItem” for TypeName.

In those cases you can check for MessageClass. If it is only a mailitem, then it will return IPL.Note. If it is a Meeting invite, then it will have the class IPM.Schedule.Meeting.Request.