摘要:在 MSDN 论坛上看到这样一个问题(原贴地址): “我在用 VSTO 2008 写一个 Outlook 2007 的插件。这个插件有一个窗体区域(Form Region)显示在‘约会’(Appointment)窗体中,我怎样才能捕捉‘约会’对象的‘保存’事件,以便在保存约会的时候执行一些我自己的代码?”     我提供了一个解决方案(其他类型的 Outlook 对象也有很类似的实现方法): 在用户区域装载的时候(FormRegionShowing 事件),把 OutlookItem 属性所引用的对象转换成 Outlook.Appointment 类型。 为 Appointment 注册 Write 事件的代码。 在 Write 事件处理方法中添加自定义代码实现业务逻辑要求。 当一个约会项目被显式(比如调用了 Save 方法或者按“保存”按钮)或者非显式(比如在关闭这个项目的窗口的时候作了答复操作)保存的时候,Write 事件就会被触发。这时候还可以通过设置 Cancel 参数来取消保存操作。 下面的代码片断展示了如何在 Form Region 里面注册 Write 事件。为了代码清晰,一切从简: 'Occurs before the form region is displayed.  'Use Me.OutlookItem to get a reference to the current Outlook item. 'Use Me.OutlookFormRegion to get a reference to the form region. Private Sub MyFormRegion_FormRegionShowing(ByVal sender As Object, _                                            ByVal e As System.EventArgs) _                                            Handles MyBase.FormRegionShowing     If TypeOf Me.OutlookItem Is Outlook.AppointmentItem Then         AddHandler CType(Me.OutlookItem, Outlook.AppointmentItem).Write, _                    AddressOf Item_Save     End If End......[阅读全文]