I am writing an Outlook add-in and want to do something (not related here) to the Destination data after (when) it was saved.
(I'm new to Outlook-Addins)
so I found that there is an AfterWrite event where I can register a method. And there is an ItemLoad event in the application.
so my first Efford was something like this:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
this.Application.ItemLoad +=
new Outlook.ApplicationEvents_11_ItemLoadEventHandler(atItemLoad);
}
public void atItemLoad(Object item)
{
Outlook.AppointmentItem aitem = item as Outlook.AppointmentItem;
if (aitem != null)
{
aitem.AfterWrite +=
new Outlook.ItemEvents_10_AfterWriteEventHandler(afterWrite);
}
}
public void afterWrite()
{
MessageBox.Show("it was written!");
}
The problem is that I do not know how to get to the Destination data that triggered the event. Application.ItemLoad registers a function that receives an object that can be passed to the Destination.
AfterWrite does not. I would like something like this:
public void afterWrite(Outlook.AppointmentItem aitem)
{
MessageBox.Show(aitem.Subject + " was written!");
}
I am afraid that I am exploring a completely wrong direction.
* , - -
:
:
private List<AppointmentEventHolder> holderList = new List<AppointmentEventHolder>();
internal class AppointmentEventHolder
{
private Outlook.AppointmentItem aitem = null;
public AppointmentEventHolder(Outlook.AppointmentItem item)
{
aitem = item;
}
public void onWrite()
{
MessageBox.Show("write: " + aitem.Subject);
}
}
public void atItemLoad(Object item)
{
Outlook.AppointmentItem aitem = item as Outlook.AppointmentItem;
if (aitem != null)
{
AppointmentEventHolder aHolder = new AppointmentEventHolder(aitem);
holderList.Add(aHolder);
aitem.AfterWrite += aHolder.onWrite;
}
}
!