Drag and drop of emails from outlook to my C# application

J

Johann Wagner

Hello!

I want to drop an email in my C# application. I get the drop event and the
dataobject. But i cannot interpret the data in the dataobject. So i cannot
get the email. I have found a code sample for getting appendix via
drag&drop, but this doesn't work for the email, too. Can somebody give me a
tip how i can get the email?

Regards,
Johann
 
D

Dmitry Streblechenko

Unless you are using Extended MAPI, there is no way to do that - besides a
couple of internal formats, drag data contains messages in the MSG format.
Or, since a user must select the messages in Outlook first to drag them,
simply query Application.ActiveExplorer.Selection collection.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
J

Johann Wagner

Hello Dmitry,

thank you for your help! I can get the actual selection as you described.

But you wrote that the drag data contains messages in MSG format. Can i get
the messages and save them to .msg files?
The FileContents Data is null so i think it must be the RenPrivateMessages.
Is that right? Can i separate the msg files from there?
Do you know how i can do that?

Johann
 
D

Dmitry Streblechenko

You need to use the CF_HDROP format and DragQueryFile() to access the
temporary file names.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
J

Johann Wagner

Hello Dmitry,

i use CSharp, so i cannot use DragQueryFile(). The format CF_HDROP is not
available, too.

The formats available are:

RenPrivateSourceFolder
RenPrivateMessages
FileGroupDescriptor
FileContents
Object Descriptor
System.String
UnicodeText
Text

The first 3 are MemoryStreams which i cannot interpret.
The FileContents is always null.
Object Descriptor is MemoryStream which i cannot interpret, too
Others are strings with the mail subject.

Do you know how i can access it in CSharp?

Johann
 
J

Johann Wagner

Thanks for the tool, but i didn't get the dragdrop data from clipboard.
Maybe it depends on that i am using CSharp and the .NET Framework.
 
D

Dmitry Streblechenko

I have no idea, but I would imagine that you can access Windows API
functions from C#.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top