Drag and Drop with Outlook is not supported by code. However there are some techniques which can provide an item drag/drop effect. The idea is to write the item to a temporary .msg file and then use OLE CF_HDROP for the drop.
Before we begin let me make this clear:
There is no specific information which can be provided as far as how to write code for doing drag/drop operations with Outlook. Outlook drag/drop with custom code is not supported. All information for educational purposes only and is to not be implemented in a production environment. Because of the unsupportable nature of the information, there is no guarantee any of the information or samples will work or will work in the future. It will be up to you to retest each and every version/service pack/hot fix for products which your code is going against. There is always a risk that future a version/service pack/hot fix for products involved may cause your code to fail. In this case, you will need to find your own alternate path to getting this to work. Information on how Outlook handles Drag and Drop is not documented and MS will not be able to provide info on this.
As an example you might do a DnD of a message from a custom dialog (of an outlook add-in) to an Outlook explorer or another outlook message (as attachment):
1) Save the selected messages as MSG files, as per the KB article below:
INFO: Save Message to MSG Compound File
2) Use the CF_HDROP DnD format for the dataobject, setting these filenames.
In a nut-shell, you can set the allowed drag-drop effects in the call to DoDragDrop. The IDropTarget will get the allowed drop effects and can choose between them depending on what it wants. The code receiving the drop can look at dwOKEffect passed to it in order to tell what the source is doing.
Drag and Drop
The operation’s allowed are supported when starting a DoDragDrop. dwOKEffect says what is allowed by the source and pdwEffect tells the source what the target actually did. So a move would be the same as a copy on the target side, and the target returns DROPEFFECT_MOVE, and the source then cuts (removes) the items. So, if you only want a copy or a move, then have the source specify it only supports a copy or a move in dwOKEffect. If you want to see if you can do a move or a copy with what’s being dropped, then check-out pdwEffect. pdwEffect is a return value from the IDropTarget. See, DragDrop doesn’t actually use the clipboard, if you really want to know the formats of a DragDrop operation, you need to implement IDropTarget, and enumerate the formats provided.
DROPEFFECT – dwOKEffect
Since the message is coming in as a file, Outlook is probably only going to handle it only as a copy (DROPEFFECT_COPY). Based-upon how I’ve seen many different APIs work with Outlook and issues of moving messaging items in and out of messaging stores, I would expect this behavior. This means, that I would expect that DROPEFFECT_COPY would only get returned by Outlook. If you copied a .MSG file from Windows Explorer and dropped in into Outlook, I’d imagine it would have similar behavior. From observations with using a CF_HDROP object with DROPEFFECT_MOVE with Outlook and from what I know of how Outlook works with supported APIs, I would conclude that Outlook only handling DROPEFFECT_COPY for the drop operation your trying. While I could look at the Outlook source in this area, I’m not going to; I’m definitely not going to document something which the Outlook product team says is not supported.
OK, now I’ve provided information on what is supported, however I cannot get into how Outlook actually works for drag/drop operations. There is no public information which can be provided as to how Outlook actually works for drag/drop – this is because that information is not documented nor is there support for this. That’s as far as we can go into how Outlook works – we cannot tell you how Outlook actually handles drops. So in the end: if this technique works, it works… if its does not, then it does not.