I'm attempting to use this code to automatically accept meeting invitations from specific senders:
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.Name = "SENDER NAME" Then
Set xMtResponse = xAppointmentItem.Respond(olResponseAccepted, True)
xMtResponse.Send
xMtRequest.Delete
End If
End If
End Sub
xMtResponse is always "nothing", so the xMtResponse.Send fails with "Object variable or With block variable not set".
What am I doing wrong?