I have an Outlook 2010 Add-In where the user drags and drops emails on a TreeView or ListView. To get these emails I am using the following code:
Outlook._Application myOlApp = new Outlook.ApplicationClass();
Outlook.Selection droppedMails = myOlApp.ActiveExplorer().Selection;
The problem is if the user selects for example three emails the droppedMails will have three emails, but after the first selection if he selects one, the droppedMails will be four.
My question is why myOlApp.ActiveExplorer().Selection is not cleared the second time? do I have to release Outlook objects?
EDIT:
The email preview in Outlook also stops working. So every selected email after drag and drop doesn't change the preview.
The problem will be solved when the user clicks on another folder in Outlook.
Thank you for your time.
After some research I found that the problem is that the dropped emails COM objects aren't being released. The easiest way to release them is to call the e.Data.GetData("RenPrivateMessages"); method after finishing the drag and drop logic in the DragDrop Event Handler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With