2013-05-07 51 views
0

我使用VS2010 - > Extensibility->共享外接 我添加了一個事件處理程序,以我的ItemSend充分利用,SentOnBehalfOfName與應收的MailItem對象(Outlook共享加載項)的名字

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,並從與電子郵件的發送帳戶名稱。

回答

1

只有在郵件實際發送並移動到「發送郵件」文件夾後,纔會設置與發件人相關的屬性。您可能需要使用已發送郵件文件夾中的Items.ItemAdd事件。

+0

我能得到哪些帳戶的電子郵件地址和帳戶名稱我送的ItemSend電子郵件只 – 2013-05-07 09:49:59

+0

是代碼,但它除非明確指定,否則可能爲null。 – 2013-05-07 19:47:00

+0

好吧我得到了我使用mailItem.SendUsingAccount;顯示名稱和解決smtpAddress – CHANDRAHAS 2013-05-09 07:06:32

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

相關問題