The following code may be used as a starting point for writing your own event handlers with regards to Outlook's AppointmentItem Object.
This code will set an object reference to any AppointmentItem (appointment, meeting) you select in an active Explorer window. Place the following code into the ThisOutlookSession module.
Private WithEvents objExplorer As Outlook.Explorer
Private WithEvents appt As Outlook.AppointmentItem
Private Sub Application_Startup()
Set objExplorer = Application.ActiveExplorer
End Sub
Private Sub objExplorer_SelectionChange()
If objExplorer.CurrentFolder.DefaultItemType = olAppointmentItem Then
If objExplorer.Selection.Count > 0 Then
Set appt = objExplorer.Selection(1)
End If
End If
End Sub
This code declares two variables that will handle events. In the Startup event, we merely initialize it to point to the active Explorer (whichever one appears when Outlook starts).
The SelectionChange event allows us to grab whatever AppointmentItem happens to be selected. That way, when we do something to it, our AppointmentItem event handlers will fire.
Here are the event handlers for the AppointmentItem Event. They should also be placed in the ThisOutlookSession module. Each one is intended simply to demonstrate how each one works and should be written. Once you place them (along with the code above) into Outlook's VB IDE, restart Outlook and then play around with meetings and appointments to see when and how each event fires.
Private Sub appt_AttachmentAdd(ByVal Attachment As Attachment)
MsgBox "AttachmentAdd Event"
End Sub
Private Sub appt_AttachmentRead(ByVal Attachment As Attachment)
MsgBox "AttachmentRead Event"
End Sub
Private Sub appt_BeforeAttachmentSave(ByVal Attachment As Attachment, _
Cancel As Boolean)
MsgBox "BeforeAttachmentSave Event"
End Sub
Private Sub appt_BeforeCheckNames(Cancel As Boolean)
MsgBox "BeforeCheckNames Event"
End Sub
Private Sub appt_BeforeDelete(ByVal Item As Object, Cancel As Boolean)
MsgBox "BeforeDelete Event"
End Sub
Private Sub appt_Close(Cancel As Boolean)
MsgBox "Close Event"
End Sub
Private Sub appt_CustomAction(ByVal Action As Object, ByVal Response As Object, _
Cancel As Boolean)
MsgBox "CustomAction Event"
End Sub
Private Sub appt_CustomPropertyChange(ByVal Name As String)
MsgBox "CustomPropertyChange Event"
End Sub
Private Sub appt_Forward(ByVal Forward As Object, Cancel As Boolean)
MsgBox "Forward Event"
End Sub
Private Sub appt_Open(Cancel As Boolean)
MsgBox "Open Event"
End Sub
Private Sub appt_PropertyChange(ByVal Name As String)
MsgBox "PropertyChange Event"
End Sub
Private Sub appt_Read()
MsgBox "Read Event"
End Sub
Private Sub appt_Reply(ByVal Response As Object, Cancel As Boolean)
MsgBox "Reply Event"
End Sub
Private Sub appt_ReplyAll(ByVal Response As Object, Cancel As Boolean)
MsgBox "ReplyAll Event"
End Sub
Private Sub appt_Send(Cancel As Boolean)
MsgBox "Send Event"
End Sub
Private Sub appt_Write(Cancel As Boolean)
MsgBox "Write Event"
End Sub
