问题
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