Tag: 外接程序

事件处理程序未添加到新邮件项目

我正在尝试创建一个简单的Outlook 2010加载项,以响应新的附件事件。 下面的代码仅在我取消注释MessageBox.Show行时才有效。 但删除它似乎不添加事件处理程序。 我对程序流的缺失是什么意味着模态消息框会影响事件处理程序的位置? public partial class ThisAddIn { private void ThisAddIn_Startup(object sender, System.EventArgs e) { Application.Inspectors.NewInspector += Inspectors_NewInspector; } void Inspectors_NewInspector(Outlook.Inspector Inspector) { Outlook.MailItem mailItem = Inspector.CurrentItem as Outlook.MailItem; if (mailItem != null) { if (mailItem.EntryID == null) { mailItem.BeforeAttachmentAdd += mailItem_BeforeAttachmentAdd; //System.Windows.Forms.MessageBox.Show(“Twice”); } } } void mailItem_BeforeAttachmentAdd(Outlook.Attachment Attachment, ref bool Cancel) { […]