我正在用VSTO为outlook开发一个插件,我试图将一个单独的表单区域显示为打开的检查器中的当前表单页面,但会抛出一个异常。这是代码
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
this.Application.Inspectors.NewInspector += InspectorsOnNewInspector;
this.Application.Explorers.NewExplorer += Explorers_NewExplorer;
}
private void Explorers_NewExplorer(Outlook.Explorer explorer)
{
}
private void InspectorsOnNewInspector(Outlook.Inspector inspector)
{
MessageBox.Show("ola");
// exception ocurrs in this line
inspector.SetCurrentFormPage("OutlookAddIn.RequestFormRegion");
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}提前谢谢。
发布于 2015-09-16 15:58:41
我设法让它使用下面的代码
private void InspectorsOnNewInspector(Outlook.Inspector inspector)
{
MessageBox.Show("ola");
if (!(inspector.CurrentItem is Outlook.TaskItem)) return;
var taskItem = (Outlook.TaskItem) inspector.CurrentItem;
taskItem.Open += (ref bool cancel) =>
{
try
{
inspector.SetCurrentFormPage("OutlookAddIn.RequestFormRegion");
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
};
}https://stackoverflow.com/questions/32612339
复制相似问题