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