0
votes

I am creating an Outlook VSTO that allows users to enter information in an additional form-region on the New appointment form. When sending the appointment I would like to capture the 'Send' event and perform some checks on the data the user provided. When this data is OK the appointment can be send, otherwise the Send action must be cancelled.

My code is like this:

Dim apptItem as Outlook.AppointmentItem

Private Sub Test_FormRegionShowing(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.FormRegionShowing
        apptItem = OutlookItem
        AddHandler apptItem.Send, AddressOf sendAppt
End Sub



    Private Sub sendAppt()
        If some_test = False then

              else
                Cancel=True
        End If
End Sub

How do I pass the event arguments to my SendAppt function so that I can cancel out of the routine and prevent the meeting from being send?

2

2 Answers

0
votes

The appointment itself is never sent - Outlook creates a brand new MeetingItem object and send it. You need to use the Application.ItemSend event and check if the Item parameter points to a MeetingItem object. You can then check which appointment it corresponds to using MeetingItem.GetAssociatedAppointment.

0
votes

Well, the answer was rather simple and the solution is like this:

Private sub SendAppt (ByRef Cancel as Boolean)
    If [some test] = False Then
        Cancel = True
    End If
End Sub

This will cancel out of the send routine and holds the meeting item from being send.