3

Background:

I am in the process of designing an application that will allow items to be dragged to it and will invoke some long running processes on them. The items will normally be dragged in from the filesystem and from Outlook. My concern is with the latter.

How can I hook into Outlook to find out if a message (or several) has been dragged out of it and on to my application and what the message ID is/are?

I understand that the Outlook object model does not have such drag/drop events and one solution is to listen to the Windows messages - this is not feasible in the team, as our combined Interop knowledge is not great.

We will be using C# 4.0 in Visual Studio 2010 for developing this application.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • can you not use the MailItem.EntryID (assuming you're looking at mail in Outlook)? – hawbsl May 21 '12 at 10:55
  • @hawbsl - Well, that's the idea. The issue is more to with intercepting drag-drop than finding the ID. – Oded May 21 '12 at 10:57
  • i see. we show a message something like "looks like you've already dragged this one across, are you sure you want to continue?" if we catch a duplicate based on its EntryID. if you're looking for something less clunky and which intercepts the user's "mistake" _earlier_ then that sounds great and i hope you get answers – hawbsl May 21 '12 at 11:02
  • @hawbsl - I don't think you follow. How do you find out that the message _has_ been dragged out of Outlook to begin with? – Oded May 21 '12 at 11:05
  • we're logging the EntryID of each successful drag & drop. later attempts to drag the same item can be cross referenced with this log. i realise this isn't going to scale to the many tens of thousands of messages, but it's working in our case. – hawbsl May 21 '12 at 11:07
  • @hawbsl - But **how** are you logging it on drag&drop from Outlook into your separate application? How do you get the data? That is what I am asking about - not about duplicates or anything like that. – Oded May 21 '12 at 11:13

2 Answers2

3

Even this is an old question, there is actually a way. It's undocumented, but I was able to reverse engineer this at least half way. I'm not sure though if the "Selection"-method is still cleaner, but I prefer to read the data directly.

A sample and the docs for this can be found here: https://github.com/yasoonOfficial/outlook-dndprotocol

mnkypete
  • 329
  • 1
  • 13
1

You cannot get access to the MailItem.EntryID directly from Outlook via the generic IDataObject drag-n-drop interface. If you just want to access the MSG data, then you can use this CodeProject example. Once an MSG is copied to disk (or clipboard, drag-n-dropped, etc.), it loses any reference to an EntryID.

The only way I know of to get access to the EntryID is by using VSTO and using the ActiveExplorer().Selection to see which items are selected at the time of the drop action. Here is an example of accessing the Body of a selected message during a drag-n-drop command. You should be able to find numerous examples once you see the general pattern being used.

Community
  • 1
  • 1
SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173