【发布时间】:2019-11-28 08:01:31
【问题描述】:
如果您在 Outlook 中有更多帐户/商店并希望触发 ItemAdd 事件,例如对于所有已发送的项目文件夹。
这是我目前所拥有的,但该事件并未针对所有已发送的项目文件夹触发:
foreach (Outlook.Store store in _outlookNameSpace.Stores)
{
// _SentItems = null;
// _items = null;
try
{
_SentItems = store.GetDefaultFolder(OlDefaultFolders.olFolderSentMail);
_items = _SentItems.Items;
_items.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(items_ItemAdd); // BUGBUG: The problem is probably here, as the object needs to be alive which is firing the event?
}
catch
{
AppUtils.DoLog("Skipping this store.");
}
}
这些家伙被定义为全局类变量:
Outlook.NameSpace _outlookNameSpace;
Outlook.MAPIFolder _SentItems;
Outlook.Items _items;
【问题讨论】: