0
我在想如何編寫一個簡單的Excel 2007加載項,但只能與我的一個郵箱進行交互。目前我有兩個電子郵件地址進入我的Outlook,每個都在特定的「郵箱」中。我想知道,我將如何爲特定郵箱指定NewMail事件?如何使用多個郵箱編程Outlook 2007加載項
或者,也許不那麼幹淨,但我怎麼能寫一個函數,如果指定哪個郵箱/電子郵件的任何新項目給...
希望這是有道理的。由於
我在想如何編寫一個簡單的Excel 2007加載項,但只能與我的一個郵箱進行交互。目前我有兩個電子郵件地址進入我的Outlook,每個都在特定的「郵箱」中。我想知道,我將如何爲特定郵箱指定NewMail事件?如何使用多個郵箱編程Outlook 2007加載項
或者,也許不那麼幹淨,但我怎麼能寫一個函數,如果指定哪個郵箱/電子郵件的任何新項目給...
希望這是有道理的。由於
爲了趕上新郵件事件,添加此代碼加載項啓動方法:
this.Application.NewMailEx +=
new Outlook.ApplicationEvents_11_NewMailExEventHandler(Application_NewMailEx);
然後添加方法來處理NewMailEx事件:
void Application_NewMailEx(string EntryID)
{
// get MailItem for this new mail
Outlook.Explorers explorers = this.Application.Explorers;
Outlook.MailItem newMail =
(Outlook.MailItem)explorers.Application.Session.GetItemFromID(EntryID, System.Reflection.Missing.Value);
// check SendUsingAccount to see if it came in mailbox we are interested in
if (newMail.SendUsingAccount.DisplayName == "[email protected]")
{
// do whatever You like
}
}
添加using語句也:
using Outlook = Microsoft.Office.Interop.Outlook;
非常感謝! – keynesiancross