Shared Add-ins for Outlook 2007 Capturing ReplyToAll Event

余生颓废 提交于 2019-12-02 09:12:40

The COM object that you expect to raise the event needs to be alive. Your code above loops through all items in the Inbox (ouch! why?) and uses the same variable on each iteration thus wiping out the previous value.
To reply to a message, it needs to be selected first, thus you only need to loop through the selected items (Explorer.Selection collection). Track the selection by hooking the Explorer.SelectionChanged event, in that event handler, loop through all items in the Explorer.Selection collaction and put them in your own List<MailItem> list. This way the objects will be alive until you remove them frm the list.
Better than that, instead of using List<MailItem> list, create your own wrapper that stores MailItem as a private member and hook up the ReplyAll event in that wrapper. This way when the event fires, your will know which MailItem object raised the event. The wrappers for each selected MailItem can then be stored in a List<MyMailItemWrapper> collection.

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