467,876 Members | 1,201 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,876 developers. It's quick & easy.

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

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
  • viewed: 6757
Share:
1 Reply
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.

Similar topics

reply views Thread by Jason Garland \(Secure Access Pty Ltd\) | last post: by
reply views Thread by Eugene | last post: by
3 posts views Thread by VB Programmer | last post: by
1 post views Thread by Piotr | last post: by
3 posts views Thread by daveward10 | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.