0

我正在使用 Vs2010 -> Extensibility->Shared Add-in 我已将事件处理程序添加到我的 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.SentOnBehalfOfNamemailItem.SendUsingAccount 我得到所有这些属性为空

请任何人帮助我,我想从SentOnBehalfOfName电子邮件中获取帐户名称。

4

2 回答 2

1

只有在邮件实际发送并移动到已发送邮件文件夹后,才会设置发件人相关属性。您可能希望在“已发送邮件”文件夹中使用 Items.ItemAdd 事件。

于 2013-05-07T06:29:31.237 回答
0

这是我使用的代码

    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);
                        }

                    }

            }
        }

感谢您的想法德米特里 Streblechenko

于 2013-05-07T07:31:21.583 回答