C# VSTO Outlook 2013 - 资源管理器关闭句柄保存事件

C# VSTO Outlook 2013 - Explorer Close handle Save Event

我有一个带一些按钮的 RibbonBar,它出现在 Outlook 资源管理器中(双击邮件)。

后台修改邮件附件部分进度。如果用户关闭Explorer,outlook会要求保存编辑过的邮件(save the changes)。

是否有处理此事件的事件?如果我的程序更改了邮件,我不希望出现该消息。

我没有成功搜索活动。但也许我只是错过了一些东西。

不需要为此处理任何事件。

If the user close the Explorer, outlook will ask to save the edited mail (save the changes).

这是一个很好的指标,表明更改未保存或 Outlook 对象(实际上是底层 COM 对象)未正确发布。使用 MSDN 中的 System.Runtime.InteropServices.Marshal.ReleaseComObject to release an Outlook object when you have finished using it. Then set a variable to Nothing in Visual Basic (null in C#) to release the reference to the object. You can read more about that in the Systematically Releasing Objects 文章。

Some progresses in the background edit the attachments of the mail.

不要从辅助线程使用 Outlook 对象模型。 Office 应用程序(在您的例子中是 Outlook)使用单线程单元模型。您可以在主线程上收集所需的信息(例如将其保存在一个字符串中)并在另一个线程上处理它。或者您可以使用允许 运行 多线程的低级 API(扩展 MAPI)。您也可以考虑在 API 周围使用任何包装器。坦率地说,Outlook 是 API.

的一个大包装