I found the code for Auto-Decline a meeting request in several locations. However, when running it in my Outlook 2013 as an action for a rule, it is stopping on the line intended to discard instead of sending the reply. The meeting organizer does not need a response from everyone in the organization. As it is on the group calendar, I don't need it on my personal as they are not meetings I get involved with.

What is causing this error and how can I best fix this issue?

The Outlook rule is aborting the script and jumping out even though I have a couple additional actions (mark it as read and delete it) when it hits the Run-time error. This is resulting in the invite remaining in my Inbox and I don't know what with spamming the organizer. I created a temp macro for testing that takes the currently selected meeting invite in Outlook, and feeds it into the AutoDecline script. This is how I'm getting the error to actually show itself.

Sub AutoDeclineMeetings(oRequest As MeetingItem)

If oRequest.MessageClass <> "IPM.Schedule.Meeting.Request" Then
    Exit Sub
End If

Dim oAppt As AppointmentItem
Set oAppt = oRequest.GetAssociatedAppointment(False)

Dim oResponse
    Set oResponse = oAppt.Respond(olMeetingDeclined, True)
    oResponse.Close (olDiscard)

'These actions I added for my rule to discard the invite from the inbox.
oRequest.UnRead = False

End Sub

Sub TestMacro()

Dim TestItem As MeetingItem
Set TestItem = ActiveExplorer.Selection.Item(1)
Call AutoDeclineMeetings(TestItem)

End Sub

On the line oResponse.Close (olDiscard) I am receiving the Run-Time error 91: Object variable or With block variable not set. What I am expecting is the Decline response to be discarded instead of sent to the meeting originator so I don't spam them. It is not needed to be accepted by everyone in the organization mailing list it was sent.

0 Answers