我正在开发 VSTO Outlook2010 客户端插件。我有一个功能区,它显示在新的电子邮件资源管理器窗口中。我需要编写一个方法,在关闭新电子邮件窗口时执行某些操作。我知道发送电子邮件时窗口会自行关闭,但我需要一种方法在关闭窗口而不发送电子邮件时触发,例如当用户想要取消时。
任何带有示例代码的想法都将不胜感激。
我从其他帖子试过这个。下面两行说:不能隐式转换类型 .存在显式转换。您缺少类型转换吗?
Inspector OpenedMailItem;
//within the start-up method
Inspector insp = this.Application.Inspectors;
insp.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(OnNewInspector);
//new function, within class
public void OnNewInspector(Outlook.Inspector inspector)
{
if (inspector.CurrentItem is Microsoft.Office.Interop.Outlook.MailItem)
{
OpenedMailItem = inspector.CurrentItem as Microsoft.Office.Interop.Outlook.MailItem;
((ItemEvents_10_Event)OpenedMailItem).Close += new Outlook.ItemEvents_10_CloseEventHandler(MailItem_Close);
}
}
void(MailItem)
{
//something
}
出现了很多错误并悬停在 sasy: cannot implicitly convert type .存在显式转换。您缺少类型转换吗?
我正在导入所有这些:
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Outlook = Microsoft.Office.Interop.Outlook;
using Excel = Microsoft.Office.Interop.Excel;
using System.Windows.Forms; using System.Net;
using System.Web; using System.IO;
using System.Text.RegularExpressions;
using Redemption;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop.Outlook;
using Exception = System.Exception;
最佳答案
捕获 Application.Inspectors.NewInspector 事件,将新检查器添加到检查器列表中。监听 Inspector.Close 事件。当它触发时,从列表中删除检查器。
关于c# - VSTO Outlook 2010 C# Active Explorer 关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25434232/