Hi,
I am trying to use the AppointmentItem's Write event to give the user an option to cancel the change to a meeting in the calendar. ItemLoadCallback is called fine whenever the appointment is opened in Outlook which is what I want. I then register the Write event, but it never triggers. I have looked in OutlookSpy and the AppointmentItem does receive the event, but I just cannot figure out why event in the code below is not reached. Does anyone have any clue why?
I am trying to use the AppointmentItem's Write event to give the user an option to cancel the change to a meeting in the calendar. ItemLoadCallback is called fine whenever the appointment is opened in Outlook which is what I want. I then register the Write event, but it never triggers. I have looked in OutlookSpy and the AppointmentItem does receive the event, but I just cannot figure out why event in the code below is not reached. Does anyone have any clue why?
_outlookApplication.ItemLoadEvent += new Outlook.Application_ItemLoadEventHandler(AddinLogic.ItemLoadCallback);
static Outlook.AppointmentItem _appointment = null;
public static void ItemLoadCallback(NetOffice.COMObject obj)
{
using (Outlook.AppointmentItem tmp = obj as Outlook.AppointmentItem)
{
if (tmp == null)
return;
_appointment = tmp;
_appointment.WriteEvent += new Outlook.AppointmentItem_WriteEventHandler(AddinLogic.AppointmentWriteEventHandler);
}
}
private static void AppointmentWriteEventHandler(ref bool Cancel)
{
// execution never gets here
int i = 9;
}