2011-01-12 24 views
3

我使用Visual Studio 2010創建Outlook 2007 Addin。現在我想知道電子​​郵件是新發送,回覆還是轉發。有沒有這方面的任何財產?如何確定電子郵件是新發送,回覆還是轉發?

using Outlook = Microsoft.Office.Interop.Outlook; 

namespace _Outlook2k7_Add_In 
{ 
    public partial class ThisAddIn 
    { 
     private void ThisAddIn_Startup(object sender, System.EventArgs e) 
     { 
     } 

     private void ThisAddIn_Shutdown(object sender, System.EventArgs e) 
     { 
     } 

     void Application_ItemSend(object Item, ref bool Cancel) 
     { 
      Outlook.MailItem mail = Item as Outlook.MailItem; 

      if (mail == null) 
       return; 

      // Magic? 
     } 

     #region VSTO generated code 

     /// <summary> 
     /// Required method for Designer support - do not modify 
     /// the contents of this method with the code editor. 
     /// </summary> 
     private void InternalStartup() 
     { 
      this.Startup += new System.EventHandler(ThisAddIn_Startup); 
      this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); 
      this.Application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend); 
     } 

     #endregion 
    } 
} 

回答

1

有跡象表明,與回覆/轉發的消息狀態處理3個擴展MAPI屬性:

PR_ICON_INDEX(0x10800003) PR_LAST_VERB_EXECUTED(0x10810003) PR_LAST_VERB_EXECUTION_TIME(0x10820040)

要得到這些值在Outlook 2007/2010中,使用PropertyAccessor對象:

http://msdn.microsoft.com/en-us/library/bb176395(office.12).aspx

如果是發送進行中,MailItem.Sent屬性仍然是False。

+0

我不是100%肯定,但我相信,MAPI屬性僅使用Exchange服務器的時候,不是POP/IMAP/SMTP設置的情況。 OP沒有說明他們正在使用哪個,所以這可能會影響它們,也可能不會影響它們。 – 2011-01-12 19:06:58

0
MAPIFolder inbox = Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderInbox); 
Items unreadItems = inbox.Items.Restrict("[UnRead] = true"); 

foreach (MailItem mail in unreadItems) 
{ 
    // Do Stuff 
} 

這似乎對我來說真的很好。我不知道mailitem本身會有這些信息。您可以過濾olFolderSentMail文件夾。

相關問題