Last active
August 18, 2016 19:14
-
-
Save Avantol13/9b0fa307d6a2804442c96211251acad4 to your computer and use it in GitHub Desktop.
Outlook VBA Script to Decline a Meeting Invitation Email Multiple Times
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NOTE: Only use on friends. | |
Must have email invite for meeting selected, then run this VBA script | |
as an Outlook Macro (Need Developer pane showing to create/use macro). | |
----------------------------------------------------------------------- | |
Function GetCurrentItem() As Object | |
Dim objApp As Outlook.Application | |
Set objApp = Application | |
On Error Resume Next | |
Select Case TypeName(objApp.ActiveWindow) | |
Case "Explorer" | |
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1) | |
Case "Inspector" | |
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem | |
End Select | |
Set objApp = Nothing | |
End Function | |
Sub Decline_Meeting() | |
Dim oAppt As AppointmentItem | |
Dim cAppt As AppointmentItem | |
Dim num_declines As Integer | |
Dim oResponse | |
Set cAppt = GetCurrentItem.GetAssociatedAppointment(True) | |
Set oAppt = Application.CreateItem(olAppointmentItem) | |
num_declines = InputBox(Prompt:="How many declines?", Title:="Decline It") | |
If num_declines < 0 Then | |
MsgBox ("Nope.") | |
ElseIf num_declines > 40 Then | |
MsgBox ("Too far. Be nice.") | |
Else | |
While num_declines > 0 | |
Set cAppt = GetCurrentItem.GetAssociatedAppointment(True) | |
Set oResponse = cAppt.Respond(olMeetingDeclined, True) | |
oResponse.Send | |
num_declines = num_declines - 1 | |
Wend | |
End If | |
Set cAppt = Nothing | |
Set oAppt = Nothing | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment