当 out 在缓存中时,Outlook 加载项不会触发
Outlook Add-in does not trigger when out is in cache
我想做的是在收到新电子邮件后执行操作。当我在 outlook 中使用在线模式时我可以使它工作,但当 outlook 处于缓存模式时则不能。否则消息不移动。
我试过了
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
outlookNameSpace = this.Application.GetNamespace("MAPI");
inbox = outlookNameSpace.GetDefaultFolder(
Microsoft.Office.Interop.Outlook.
OlDefaultFolders.olFolderInbox);
items = inbox.Items;
items.ItemAdd +=
new Outlook.ItemsEvents_ItemAddEventHandler(Quarantine);
}
和
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
//triggers when new email comes in
this.Application.NewMail += new Microsoft.Office.Interop.Outlook.
ApplicationEvents_11_NewMailEventHandler
(Quarantine);
}
我也尝试过 NewMailEx,但即使 outlook 使用在线模式也无法触发,所以我不知道该怎么做。
您需要处理 NewMailEx
事件,该事件针对 Microsoft Outlook 处理的每个收到的项目触发一次。该项目可以是几种不同项目类型中的一种,例如 MailItem
、MeetingItem
或 SharingItem
。 EntryIDsCollection
字符串包含对应于该项目的条目 ID。以下是 MSDN 的内容:
The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item. Use this method with caution to minimize the impact on Outlook performance. However, depending on the setup on the client computer, after a new message arrives in the Inbox, processes like spam filtering and client rules that move the new message from the Inbox to another folder can occur asynchronously. You should not assume that after these events fire, you will always get a one-item increase in the number of items in the Inbox.#
当一个或多个项目被添加到指定的集合时,ItemAdd
事件被触发。当大量项目一次添加到文件夹时,此事件不会 运行。
最后,ItemAdd
和 NewMailEx
事件处理程序的签名不同。您不能使用相同的函数来处理它们。
我想做的是在收到新电子邮件后执行操作。当我在 outlook 中使用在线模式时我可以使它工作,但当 outlook 处于缓存模式时则不能。否则消息不移动。
我试过了
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
outlookNameSpace = this.Application.GetNamespace("MAPI");
inbox = outlookNameSpace.GetDefaultFolder(
Microsoft.Office.Interop.Outlook.
OlDefaultFolders.olFolderInbox);
items = inbox.Items;
items.ItemAdd +=
new Outlook.ItemsEvents_ItemAddEventHandler(Quarantine);
}
和
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
//triggers when new email comes in
this.Application.NewMail += new Microsoft.Office.Interop.Outlook.
ApplicationEvents_11_NewMailEventHandler
(Quarantine);
}
我也尝试过 NewMailEx,但即使 outlook 使用在线模式也无法触发,所以我不知道该怎么做。
您需要处理 NewMailEx
事件,该事件针对 Microsoft Outlook 处理的每个收到的项目触发一次。该项目可以是几种不同项目类型中的一种,例如 MailItem
、MeetingItem
或 SharingItem
。 EntryIDsCollection
字符串包含对应于该项目的条目 ID。以下是 MSDN 的内容:
The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item. Use this method with caution to minimize the impact on Outlook performance. However, depending on the setup on the client computer, after a new message arrives in the Inbox, processes like spam filtering and client rules that move the new message from the Inbox to another folder can occur asynchronously. You should not assume that after these events fire, you will always get a one-item increase in the number of items in the Inbox.#
当一个或多个项目被添加到指定的集合时,ItemAdd
事件被触发。当大量项目一次添加到文件夹时,此事件不会 运行。
最后,ItemAdd
和 NewMailEx
事件处理程序的签名不同。您不能使用相同的函数来处理它们。