By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,215 Members | 1,920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,215 IT Pros & Developers. It's quick & easy.

Drag & Drop Outlook.MailItem to a Windows.Forms.Form and save it

P: n/a
Hi,

if I drag an Outlook.MailItem to a Windows-Explorer window a
<subject>.msg file will be created.

Now I try to drag & drop a mail item to my own WinForm app.
Unfortunately it doesn't work. In the "drop event" are eight
DataFormats (e.Data.GetFormats()) but the important one (imho)
"FileContents" is "Nothing"/"null".

Any ideas?
Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Karsten,
I've been trying to get this to work my self, but so far haven't gotten any
further than to be able to drag and attachment in a mail to aWinForm.
The basic thinking behind a mail being dragged is a whole lot of COM and
interfaces. Here's the short version:

The objects (the mail(s)) being dropped is a COM class of IDataObject
interface.
It contains aFileGroupDescripter structure that contains an array of objects
(mails), so you can drag several mails at once.
Using the FORMATEDC and STGMEDIUM structures, it should be possible to get
the filename of the mail (eg. Message.msg), and a IStream interface to the
actual mail.
Once you have the IStream interface, it's easy to save it, but actually
getting there is much harder than what I had thought.

If you search MSDN, you'll find some samples on the various structures -
it's the same stuff MS uses for drag'n'drop and objects over the clipboard.
I have a C++ sample that does it all, as well as some VB.NET and C#.NET code
that allows you to drag an attachment from a mail. But not a .NET one that
saves the full mail.

Let me know if you want it - my email is (remove the spam)
sp****@spamlector.spamdk
Perhaps we can get this shit to work together?

/Thomas

"Karsten Schramm" <me*******@gmx.de> wrote in message
news:eb**************************@posting.google.c om...
Hi,

if I drag an Outlook.MailItem to a Windows-Explorer window a
<subject>.msg file will be created.

Now I try to drag & drop a mail item to my own WinForm app.
Unfortunately it doesn't work. In the "drop event" are eight
DataFormats (e.Data.GetFormats()) but the important one (imho)
"FileContents" is "Nothing"/"null".

Any ideas?

Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.