How to Create listener Outlook.ItemsEvents_ItemAddEventHandler for every mail folder?

谁说胖子不能爱 提交于 2019-12-11 10:18:28

问题


I can listen on default folder like this:

_outlookNameSpace = this.Application.GetNamespace("MAPI");
_inbox = _outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
_items = _inbox.Items;
_items.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(items_ItemAdd);

How can I add a listener on all folders and sub folders ?

Or listen for all incoming mail before it is placed in a folder or subfolder ?


回答1:


You need to store Items objects in a list (not just the _items variable) and set up the ItemAdd event handler on all folders that you are interested in.



来源:https://stackoverflow.com/questions/22147173/how-to-create-listener-outlook-itemsevents-itemaddeventhandler-for-every-mail-fo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!