0

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.

SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
Chris McAtackney
  • 5,192
  • 8
  • 45
  • 69
  • Try narrowing your question down to a specific use case instead of trying to solve all your drag-n-drop problems with one post. Clearly explain where you are dragging from (*Outlook, WPF, WinForms, Explorer, etc.*) and where you are dragging to - it's hard to follow. Identifying the source and target will make it easier for us to provide you with guidance. – SliverNinja - MSFT Sep 24 '12 at 14:40
  • @SliverNinja: Apologies, I was in a bit of a hurry when writing my post. My sources were both Outlook and Explorer, and my target is Outlook. I've actually come up with a solution that I'm fairly happy with using a timer. I'll post the code up when I get a chance in case it's useful to anyone else. – Chris McAtackney Oct 01 '12 at 13:32

1 Answers1

1

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.

Nitheen Rao
  • 210
  • 2
  • 11