Auto Reject Meeting Request in Outlook
Below is some sample code to automatically reject Outlook Meetings requests at certain times.
To use it.
- Open Outlook.
- Press
Alt-F11
to open Microsoft Visual Basic for Application. - Selected the project on the left and side, and then select “ThisOutlookSession”
- Paste the code below.
- Next, create a new mail rule
- Select on Apply Rule on Messages I Receive.
- Next, Select “Which is a meeting request of Update
- Next, Select “Run a Script”, and select “AutoRejectMeetings”
Of course you can always add more filters to it … for example you may not want to don’t run the script if it’s from your boss :-).
Sub AutoRejectMeetings(oRequest As MeetingItem)
If oRequest.MessageClass <> "IPM.Schedule.Meeting.Request" Then
Exit Sub
End If
Dim oAppt As AppointmentItem
Set oAppt = oRequest.GetAssociatedAppointment(True)
lStartHour = Hour(oAppt.Start) ' 24 Hour
lStartMinute = Minute(oAppt.Start)
lEndhour = Hour(oAppt.End) ' 24 Hour
lEndMinute = Minute(oAppt.End)
lDayOfWeek = Weekday(Appt.Start) ' 1=Sunday, 2=Monday ...
'MsgBox "(" & lDayOfWeek & ")" & lStartHour & ":" & lStartMinute & " - " & lEndhour & ":" & lEndMinute
If (lEndhour > 16) Or (lEndhour = 16 And lEndhour > 0) Then
Dim oResponse
' olMeetingTentative/olMeetingAccepted/olMeetingDeclined
Set oResponse = oAppt.Respond(olMeetingTentative, True)
' Body is optional.
oResponse.Body = "Hi," & vbNewLine & vbNewLine & "I'm usually out of the office a 4pm. " & vbNewLine & vbNewLine & "Colin."
oResponse.Send
End If
End Sub
Last modified on 2015-03-11