我正在使用VSTO在发送电子邮件时创建事件。目标是改变附件。 我已经有其他addins在ItemSend事件中运行,但问题是,我想我的插件先运行。因为我读,有在Outlook中没有执行顺序加载项发送的事件,但必须有某种秩序,即使只有名称或GUID ....C#VSTO Outlook ItemSend事件执行顺序
我尝试此解决方案(问题是,如果我有2个邮件窗口打开,第一个窗口鸵鸟政策运行事件... :(有一些覆盖事件问题)
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
this.Application.Inspectors.NewInspector += new InspectorsEvents_NewInspectorEventHandler(Custom_Inspector);
//This run in the end off all ItemSend Events.... :(
//this.Application.ItemSend += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(MyFunction2);
}
private void Custom_Inspector(Inspector Inspector)
{
if (Inspector != null && Inspector.CurrentItem != null && Inspector.CurrentItem is Outlook.MailItem)
{
Outlook.MailItem mailItem = Inspector.CurrentItem as Outlook.MailItem;
if (mailItem.EntryID == null)
{
((ItemEvents_10_Event)mailItem).Send += new ItemEvents_10_SendEventHandler(MyFunction);
}
}
}
void MyFunction(ref bool Cancel)
{
MailItem mailItemContext = ((Inspector)this.Application.ActiveWindow()).CurrentItem as MailItem;
if (mailItemContext != null)
{
//my custom code here
}
}
尤金你能帮我在我的评论? – rockxl1