Event After Outlook Appointment Was Saved

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()
{
    // Who was written?
    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)
{
    // do something with the data from the Appointment
    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;
    }
}

!

+5
1

, , .
, .

, crutial, , , .

private Outlook.MAPIFolder _CalendarFolder = null;
private Outlook.Items _CalendarItems = null;

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
    Outlook.MAPIFolder calendarFolder =
        this.Application.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);

    // get the Termine24-Folder (if not found, create it)
    try
    {
        _CalendarFolder = calendarFolder.Folders[Constants.FOLDERNAME];
    }
    catch
    {
        _CalendarFolder = calendarFolder.Folders.Add(Constants.FOLDERNAME);
    }
    _CalendarItems = _CalendarFolder.Items;
    attachEvents();

}
public void attachEvents()
{
    _CalendarItems.ItemAdd += Item_Add;
    _CalendarItems.ItemChange += Item_Change;
    _CalendarItems.ItemRemove += Item_Remove;
}
public void Item_Add(Object item)
{
    Outlook.AppointmentItem aitem = item as Outlook.AppointmentItem;
    if (aitem != null)
    {
        MessageBox.Show("add: " + aitem.Subject);
    }
    else
    {
        MessageBox.Show("add, but no appointment");
    }
}
public void Item_Change(Object item)
{
    Outlook.AppointmentItem aitem = item as Outlook.AppointmentItem;
    if (aitem != null)
    {
        MessageBox.Show("changed: " + aitem.Subject);
    }
    else
    {
        MessageBox.Show("change, but no appointment");
    }
}
public void Item_Remove()
{
    MessageBox.Show("Item_remove");
}

, , .

Item_Remove , .

+6

All Articles