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

Drag & Drop of Outlook message + attachments to VB.Net form

P: n/a
Does anyone know how to drag&drop a message with attachments from Outlook
(2002 or 2003) in to a VB.Net windows form.
This is really stumping me. I've spent a fair amount of time trying to find
a solution on the internet, with limited success.

I do have code to drag an attachment directly from Outlook to a form, but
not a whole message.
I want to have access to an object reprensenting the message so I can bust
out the message and attachments individually.

I have implemented a solution involving dragging the e-mail message from
Outlook to the desktop, then from the desktop to the windows form, but the
users don't want to do that and I don't think they should have to.

I've seen libraries and code that seem to make this easy using VB6, C++, or
COM, but almost nothing in .Net except simple examples of either files or
tree items, not Outlook e-mails directly onto VB.Net Winforms.

Any help appreciated.
Dave Anderson.
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
David,

Mostly is implementing code in VBNet simple when you know the VBA code used
in outlook, did you ask this already in a VBA Outlook newsgroup?

Cor
Nov 21 '05 #2

P: n/a
David,
Unfortunately the format Outlook uses for Drag & Drop is not defined. You
can use the IDataObject.GetFormats to see the formats that Outlook is
offering to your app. However how to use the interesting formats that
probably contain the actual message is not defined.

Hope this helps
Jay

"David Anderson" <an******@one.net> wrote in message
news:eb**************@tk2msftngp13.phx.gbl...
Does anyone know how to drag&drop a message with attachments from Outlook
(2002 or 2003) in to a VB.Net windows form.
This is really stumping me. I've spent a fair amount of time trying to
find
a solution on the internet, with limited success.

I do have code to drag an attachment directly from Outlook to a form, but
not a whole message.
I want to have access to an object reprensenting the message so I can bust
out the message and attachments individually.

I have implemented a solution involving dragging the e-mail message from
Outlook to the desktop, then from the desktop to the windows form, but the
users don't want to do that and I don't think they should have to.

I've seen libraries and code that seem to make this easy using VB6, C++,
or
COM, but almost nothing in .Net except simple examples of either files or
tree items, not Outlook e-mails directly onto VB.Net Winforms.

Any help appreciated.
Dave Anderson.

Nov 21 '05 #3

P: n/a
RD
I have probably tried the same things that you have with the same
results. I do have a potential workaround. You have been trying to
get to the MailItem by looking at the DragEventArgs. What you should
be able to do is use the DragEventArgs to determine if the dropped
item is an Outlook item. (I think that the objectdescriptor format
will have the text "Outlook".) If it is Outlook then use the Outlook
object model to get the message with code similar to:

Outlook._Application myOlApp=new Outlook.ApplicationClass();
Outlook._Explorer myExp=myOlApp.ActiveExplorer();
Outlook._MailItem myMailItem=(Outlook.MailItem)myExp.Selection.Item( 1);
string txtBody=myMailItem.Body;

Now you have the MailItem and you can do whatever you like. Since
this is on the drop event the ActiveExplorer should be the outlook
instance that you dragged from. Likewise the item you are dragging
would still be the active selection. Sorry I gave you the snippet in
C#, but you get the point. Hope that helps.
Nov 21 '05 #4

P: n/a
RD,
Interesting kludge, it just might work.

If I find time I may look at this later.
Jay

"RD" <go****@pcsaddons.com> wrote in message
news:19**************************@posting.google.c om...
I have probably tried the same things that you have with the same
results. I do have a potential workaround. You have been trying to
get to the MailItem by looking at the DragEventArgs. What you should
be able to do is use the DragEventArgs to determine if the dropped
item is an Outlook item. (I think that the objectdescriptor format
will have the text "Outlook".) If it is Outlook then use the Outlook
object model to get the message with code similar to:

Outlook._Application myOlApp=new Outlook.ApplicationClass();
Outlook._Explorer myExp=myOlApp.ActiveExplorer();
Outlook._MailItem myMailItem=(Outlook.MailItem)myExp.Selection.Item( 1);
string txtBody=myMailItem.Body;

Now you have the MailItem and you can do whatever you like. Since
this is on the drop event the ActiveExplorer should be the outlook
instance that you dragged from. Likewise the item you are dragging
would still be the active selection. Sorry I gave you the snippet in
C#, but you get the point. Hope that helps.

Nov 21 '05 #5

P: n/a
Go to the following site for an example:
http://codeproject.com/csharp/TestEmailDragDrop.asp

I have a treeview control that user drop either an email or an attachment
to, that I then save as an image.

Chuck

"David Anderson" wrote:
Does anyone know how to drag&drop a message with attachments from Outlook
(2002 or 2003) in to a VB.Net windows form.
This is really stumping me. I've spent a fair amount of time trying to find
a solution on the internet, with limited success.

I do have code to drag an attachment directly from Outlook to a form, but
not a whole message.
I want to have access to an object reprensenting the message so I can bust
out the message and attachments individually.

I have implemented a solution involving dragging the e-mail message from
Outlook to the desktop, then from the desktop to the windows form, but the
users don't want to do that and I don't think they should have to.

I've seen libraries and code that seem to make this easy using VB6, C++, or
COM, but almost nothing in .Net except simple examples of either files or
tree items, not Outlook e-mails directly onto VB.Net Winforms.

Any help appreciated.
Dave Anderson.

Nov 21 '05 #6

P: n/a
Go to the following site for an example of how to trap this:
http://codeproject.com/csharp/TestEmailDragDrop.asp

I have a treeview control that user drag an entire email, with attachments,
or just an attachment to, and I then save the contents as an image.

"David Anderson" wrote:
Does anyone know how to drag&drop a message with attachments from Outlook
(2002 or 2003) in to a VB.Net windows form.
This is really stumping me. I've spent a fair amount of time trying to find
a solution on the internet, with limited success.

I do have code to drag an attachment directly from Outlook to a form, but
not a whole message.
I want to have access to an object reprensenting the message so I can bust
out the message and attachments individually.

I have implemented a solution involving dragging the e-mail message from
Outlook to the desktop, then from the desktop to the windows form, but the
users don't want to do that and I don't think they should have to.

I've seen libraries and code that seem to make this easy using VB6, C++, or
COM, but almost nothing in .Net except simple examples of either files or
tree items, not Outlook e-mails directly onto VB.Net Winforms.

Any help appreciated.
Dave Anderson.

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.