I had two questions this week that were similar. In one, the user wanted to decline a meeting but keep a copy of the appointment, the other user wanted to forward accepted meeting to another mailbox.
While these requests don't sound all that similar, the same basic VBA code can be used for both. With one request, we need to copy the fields to a new appointment then decline the meeting, the other one is forwarded then accepted. You can use the basics of these macros to do other things with incoming meeting requests.
Both macros need the GetCurrentItem function listed at the end of this page. This allows you to either select a meeting request in the message list in your inbox or open it to accept or decline.
Rather than using the Accept or Decline buttons, you need to use the macro to accept or decline the meeting then "do whatever". You can add the macro to a button on your QAT, ribbon, or toolbar.

Accept and forward a meeting
Don't forget to also add the GetCurrentItem (at the end of this page) to Outlook's VBA editor.
Sub AcceptandForward() Dim oAppt As MeetingItem Dim cAppt As AppointmentItem Dim oRequest As MeetingItem Dim oResponse Set cAppt = GetCurrentItem.GetAssociatedAppointment(True) Set oRequest = GetCurrentItem() Set oAppt = oRequest.Forward oAppt.Recipients.Add "alias@domain.com" oAppt.Send Set oResponse = cAppt.Respond(olMeetingAccepted, True) oResponse.Send Set cAppt = Nothing Set oAppt = Nothing Set oRequest = Nothing End Sub
Decline and keep a copy of the meeting
Don't forget to also add the GetCurrentItem (at the end of this page) to Outlook's VBA editor.
Sub SaveAndDecline()
Dim oAppt As AppointmentItem
Dim cAppt As AppointmentItem
Dim oResponse
Set cAppt = GetCurrentItem.GetAssociatedAppointment(True)
Set oAppt = Application.CreateItem(olAppointmentItem)
With oAppt
.Subject = "Declined: " & cAppt.Subject
.Start = cAppt.Start
.Duration = cAppt.Duration
.Location = cAppt.Location
.Save
End With
Set oResponse = cAppt.Respond(olMeetingDeclined, True)
oResponse.Send
Set cAppt = Nothing
Set oAppt = Nothing
End Sub
Accept and Move the invite
When you accept a meeting, the invitation is moved to the deleted items folder. Moving it to another folder is just 4 added lines. Use the macro at the top of the page and add these lines, with oRequest.Move after the Send (or Display) line.
The folder needs to exist at the same level as the Inbox. If you want to move it to subfolder, use Session.GetDefaultFolder(olFolderInbox).Folders("SharedCal"); to use a folder outside of the current data file, see Working with VBA and non-default Outlook Folders.
' add to top section
Dim myFolder As Outlook.folder
' add after Dim section
Set myFolder = Session.GetDefaultFolder(olFolderInbox).Parent.Folders("Accepted Invites")
oResponse.Send
oRequest.Move myFolder
'last line before end sub
Set myFolder = Nothing
GetCurrentItem Function
With either of these macros (and many others on this site), you need to use the GetCurrentItem function if you want to use the macro with either opened items or selected items. You only need to have this once within your VBA project and can use it with as many macros as you want.
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
How to add the macro to Outlook and create a toolbar button
Note: you'll also need to open a meeting request and add a button to it, if you want the macro easily accessible from an opened message.

