Oded
Oded

Reputation: 499132

Drag items out of Outlook - record message ids

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.

Upvotes: 3

Views: 1543

Answers (2)

mnkypete
mnkypete

Reputation: 329

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

Upvotes: 3

SliverNinja - MSFT
SliverNinja - MSFT

Reputation: 31651

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.

Upvotes: 1

Related Questions