C# 从MailItem对象(Outlook共享加载项)获取发件人、SentonBehalfName和帐户名

C# 从MailItem对象(Outlook共享加载项)获取发件人、SentonBehalfName和帐户名,c#,outlook-addin,mailitem,shared-addin,C#,Outlook Addin,Mailitem,Shared Addin,我正在使用Vs2010->扩展性->共享加载项 我已将事件处理程序添加到ItemSend applicationObject.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(applicationObject_ItemSend); void applicationObject_ItemSend(object Item, ref bool Cancel) { if(Item is Outlook.Ma

我正在使用Vs2010->扩展性->共享加载项 我已将事件处理程序添加到ItemSend

applicationObject.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(applicationObject_ItemSend);  

void applicationObject_ItemSend(object Item, ref bool Cancel)
{
    if(Item is Outlook.MailItem)
    {
        Outlook.MailItem mailItem = Item as Outlook.MailItem;
        if (mailItem != null)
        {
           MessageBox.Show("Sender's Email Address "+mailItem.SenderEmailAddress);
           MessageBox.Show("Sender's Email Address "+mailItem.SentOnBehalfOfName); 
          MessageBox.Show("Sender's Email Address "+mailItem.SendUsingAccount);
        }
    }
}
mailItem.SenderEmailAddress,mailItem.SentOnBehalfOfName
mailItem.SendUsingAccount
我正在将所有此属性设置为空

请问有人能帮我吗
我想从发送电子邮件时的、
SentOnBehalfOfName
和帐户名中获取。只有在邮件实际发送并移动到“已发送邮件”文件夹后,才会设置与发件人相关的属性。您可能希望在Sent Items文件夹中使用Items.ItemAdd事件。

这是我使用的代码

    public Outlook.MAPIFolder sentFolder = null;
    public Outlook.Items itmsSentFolder = null;
    sentFolder = applicationObject.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail);
    itmsSentFolder = sentFolder.Items;
    itmsSentFolder.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(itmsSentFolder_ItemAdd); 
void itmsSentFolder_ItemAdd(object Item)
        {

                if (Item is Outlook.MailItem)
                {
                    Outlook.MailItem mailItem = Item as Outlook.MailItem;
                    if (mailItem != null)
                    {
                        MessageBox.Show("Sender's Email Address " + mailItem.SenderEmailAddress);
                        MessageBox.Show("Sent On Behalf Of Name " + mailItem.SentOnBehalfOfName);
                        Outlook.Account ac = (Outlook.Account)mailItem.SendUsingAccount;
                        if(ac != null)
                        {
                            MessageBox.Show("Sender's Account Name " + ac.SmtpAddress);
                        }

                    }

            }
        }

感谢Dmitry Streblechenko的想法

我可以获取我正在以ItemSend onlyYes发送电子邮件的帐户的电子邮件地址和帐户名吗?但除非明确指定,否则它可能是空的。好的,我找到了使用mailItem.SendUsingAccount的方法;显示名称和解析的smtpAddress属性绝对没有理由这样做-每个Account对象都公开Account.CurrentUser属性(返回收件人对象)。