VSTO Item events add and remove ...

L

lg

Hi,
I am creating an addin for Outlook using VSTO in C#. What I want to
do is catch the write event on an appointment item. I have created a wrapper
class to store the item object and to implement the events to be handled.
When the NewInspector event on the main addin is called I add an open event
and a write event to the item by using:

((Outlook.ItemEvents_10_Event)hAppointmentItem).Open += new
Outlook.ItemEvents_10_OpenEventHandler(ThisApplication_Open);

((Outlook.ItemEvents_10_Event)hAppointmentItem).Write += new
Outlook.ItemEvents_10_OpenEventHandler(ThisApplication_Write);

What I want to do is when the item is closed and saved, I want to keep the
write event with the item so if a user drags the appointment item on the
calander to a different date without opening the item, the write event will
trigger. The problem is when the saved item is opened again, another write
event is attached to the item object. I have tried using:

((Outlook.ItemEvents_10_Event)hAppointmentItem).Write -= new
Outlook.ItemEvents_10_OpenEventHandler(ThisApplication_Write);

before re-adding the write event again but it dosnt work and dosnt throw an
exception either (as would be expected if the write event object had nothing
assigned to it). Does anyone have any idea's on this ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top