0

I'm trying to automatically accepting meetings or remove cancelled meetings in Outlook 2016 (enterprise) from a specific address (external) with VBA. So far I found the code below, which seems to be partially working.

if I change the getorganizer.address to getorganizer.name (to the display name) it works for contacts within my addressbook except for canceled meetings that still doesn't work. But I want to make this work for an external email address. Therefor I changed it to getorganizer.address but it doesn't do anything, not for meeting requests or canceled meetings.

I have this code in VBA "ThisOutlookSession"

according to chatgpt and bard this code should work, any one got suggestions?

Public WithEvents GItems As Outlook.Items
Private Sub Application_Startup()
   Set GItems = Outlook.Application.Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub GItems_ItemAdd(ByVal Item As Object)
Dim xMtRequest As MeetingItem
Dim xAppointmentItem As AppointmentItem
Dim xMtResponse As MeetingItem
If Item.Class = olMeetingRequest Then
    Set xMtRequest = Item
    Set xAppointmentItem = xMtRequest.GetAssociatedAppointment(True)
    If xAppointmentItem.GetOrganizer.Address = "someone@someone.com" Then
        With xAppointmentItem
            .ReminderMinutesBeforeStart = 5
            .Categories = "Orange Categorie"
            .Save
        End With
        Set xMtResponse = xAppointmentItem.Respond(olMeetingAccepted)
        xMtResponse.Send
        xMtRequest.Delete
     End If
       With xAppointmentItem
          If xAppointmentItem.MeetingStatus = olMeetingCanceled Then
             .Accept
             .Save
             .Delete
          End If
       End With
End If
End Sub
Jason Aller
  • 3,541
  • 28
  • 38
  • 38

0 Answers0