Below is some sample code to automatically reject Outlook Meetings requests at certain times.

To use it.

  1. Open Outlook.
  2. Press Alt-F11 to open Microsoft Visual Basic for Application.
  3. Selected the project on the left and side, and then select “ThisOutlookSession”
  4. Paste the code below.
  5. Next, create a new mail rule
  6. Select on Apply Rule on Messages I Receive.
  7. Next, Select “Which is a meeting request of Update
  8. 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