Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何以及在何处运行取决于发送方的代码';地址_C#_Outlook_Outlook Addin - Fatal编程技术网

C# 如何以及在何处运行取决于发送方的代码';地址

C# 如何以及在何处运行取决于发送方的代码';地址,c#,outlook,outlook-addin,C#,Outlook,Outlook Addin,我试图构建的外接程序必须根据发件人的地址更改新邮件的密件抄送字段 由于我是Outlook编程新手,因此我完成了这项工作并构建了示例加载项。 他们使用的事件是,正如您所看到的,在新outlook项目窗口出现之前立即触发。但是,如果我们将此代码粘贴到NewInspector事件处理程序中: Outlook.MailItem item = Inspector.CurrentItem as Outlook.MailItem; if (item != null)

我试图构建的外接程序必须根据发件人的地址更改新邮件的密件抄送字段

由于我是Outlook编程新手,因此我完成了这项工作并构建了示例加载项。 他们使用的事件是,正如您所看到的,在新outlook项目窗口出现之前立即触发。但是,如果我们将此代码粘贴到NewInspector事件处理程序中:

        Outlook.MailItem item = Inspector.CurrentItem as Outlook.MailItem;
        if (item != null)
        {
            if (item.EntryID == null)
            {
                if (item.SenderEmailAddress == "...")
                    item.BCC = "....";
            }
        }
它不起作用,因为当窗口刚刚加载时,发件人的地址是空的

我考虑过使用事件,创建的每个新邮件都会将其发送事件处理程序附加到一个方法上,该方法在发送电子邮件时会根据发件人的地址更改密件抄送

唯一的问题是,由于某些原因,我无法在VS2010 Pro中看到发送事件


有没有其他方法可以满足我的需要?

您需要使用的事件接口(),因为它有一个和绑定到同一个名称(
发送
)。这只是Outlook对象模型中必须注意的一个怪癖。这应该适合您:

((Outlook.ItemEvents_10_Event)MailItem).Send += new Outlook.ItemEvents_10_SendEventHandler(MailItem_Send);