我正在编写一个 Outlook 加载项,并希望在保存约会之后(何时)对约会的数据做一些事情(此处不相关)。
(我是 Outlook-Addins 的新手)
所以我发现有一个AfterWrite事件,我可以在其中注册一个方法。Application上有一个ItemLoad事件。
所以我的第一个 Efford 是这样的:
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!");
}
问题是,我不知道如何获取触发事件的约会数据。
Application.ItemLoad注册了一个获取 Object 的函数,该函数可以转换为Appointment。
AfterWrite没有。我想要这样的东西:
public void afterWrite(Outlook.AppointmentItem aitem)
{
    // do something with the data from the Appointment
    MessageBox.Show(aitem.Subject + " was written!");
}
我担心我在研究完全错误的方向..
*对不起,如果我的英语一团糟-这不是我的母语
编辑:
我什至尝试过这样的构造:
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;
    }
}
但事件不会被解雇!我现在很沮丧