Chris McAtackney
Chris McAtackney

Reputation: 5232

Outlook Drag and Drop - ActiveExplorer().Selection() doesn't contain all items

In my Outlook add-in, I'm attempting to obtain information on all items that are dragged and dropped by the user into a MAPI store (I'm using the Redemption library).

My first attempt at this has been to hook into the MessageCreated event...

myRDOStore.OnMessageCreated += new IRDOStoreEvents_OnMessageCreatedEventHandler(myRDOStore_OnMessageCreated);

The tricky part is that I need to capture all items which are dragged and dropped at the same time as one collection, which I guess means persisting some aspect of each new message that comes in (probably the EntryId).

Now, the problem is clearly that I have no way of tying the results of a bunch of arbitrary events together, so I was looking into the ActiveExplorer().Selection collection and trying to think of ways of determine which items had been dragged and dropped into my stored from that.

I didn't have much luck with that, as the contents of the collection seemed a bit haphazard (e.g. when dragging 1 item, there would be two items in Selection when I examined it in the event handler, or when a series of events fired there would be e.g. 2 items in Selection, then 1 on the next event, then 1 in the next etc).

In addition to that, one of my use cases is the ability to drag items from outside Outlook, which I'm guessing would not be included in the Selection collection.

Are there any standard approaches to this problem? It seems like something that would be quite common - to drag a bunch of files into a folder and be able to obtain some information on them as a collection, but I just can't figure it out. Any guidance is much appreciated.

Upvotes: 0

Views: 751

Answers (1)

Nitheen Rao
Nitheen Rao

Reputation: 210

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.

Upvotes: 1

Related Questions