473,325 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Drag and Drop from Outlook to Vb.net RichTextBox

I want to drag a message from Outlook to a richtextbox on a vb.net form. I
don't get the message body. I have searched all over the place and found
nothing.

Does anyone know how to do this? I don't care about attachments. I just
need the text.

Thanks,

Shane
Aug 24 '06 #1
4 14535
If you open the message you can just select and drag drop the body to the
richtextbox like this:

Private Sub RichTextBox1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragEnter
If (e.Data.GetDataPresent(DataFormats.StringFormat)) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub

Private Sub RichTextBox1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragDrop
RichTextBox1.Text =
e.Data.GetData(DataFormats.StringFormat).ToString
End Sub

I don't think it's possible to get the message by only dragging and dropping
the message header, I think you can only get From, Subject, Received, and
Size this way

Hope this helps

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"SStory" <no****@nospam.comschreef in bericht
news:uD**************@TK2MSFTNGP05.phx.gbl...
I want to drag a message from Outlook to a richtextbox on a vb.net form.
I
don't get the message body. I have searched all over the place and found
nothing.

Does anyone know how to do this? I don't care about attachments. I just
need the text.

Thanks,

Shane


Aug 24 '06 #2
That's a real bummer, because you can drag and drop to the desktop and get
everything it seems in an .msg file.
"Peter Proost" <pp*****@nospam.hotmail.comwrote in message
news:OW**************@TK2MSFTNGP05.phx.gbl...
If you open the message you can just select and drag drop the body to the
richtextbox like this:

Private Sub RichTextBox1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragEnter
If (e.Data.GetDataPresent(DataFormats.StringFormat)) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub

Private Sub RichTextBox1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragDrop
RichTextBox1.Text =
e.Data.GetData(DataFormats.StringFormat).ToString
End Sub

I don't think it's possible to get the message by only dragging and
dropping
the message header, I think you can only get From, Subject, Received, and
Size this way

Hope this helps

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"SStory" <no****@nospam.comschreef in bericht
news:uD**************@TK2MSFTNGP05.phx.gbl...
>I want to drag a message from Outlook to a richtextbox on a vb.net form.
I
>don't get the message body. I have searched all over the place and found
nothing.

Does anyone know how to do this? I don't care about attachments. I just
need the text.

Thanks,

Shane



Aug 24 '06 #3
After some researching I got a working sample using outlook automation, you
need a reference to the outlook object library for it to work. It check's to
see if the "Object Descriptor" contains outlook, the it opens an
outlookapplication class and get's the active explorer selected message,
from this the message body is retrieved.

Hope this helps
Private Sub RichTextBox1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragEnter
If e.Data.GetDataPresent("Object Descriptor") Then
e.Effect = DragDropEffects.Copy
'(0): "RenPrivateSourceFolder"
'(1): "RenPrivateMessages"
'(2): "FileGroupDescriptor"
'(3): "FileContents"
'(4): "Object Descriptor"
'(5): "System.String"
'(6): "UnicodeText"
'(7): "Text"
Else
e.Effect = DragDropEffects.None
End If

End Sub

Private Sub RichTextBox1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragDrop
If (e.Data.GetDataPresent("Object Descriptor")) Then
Dim myMem As New MemoryStream
Dim myByte As Byte()
Dim strCheck As String
myMem = DirectCast(e.Data.GetData("Object Descriptor"),
MemoryStream)
myByte = myMem.ToArray
myMem.Close()
For i As Integer = 0 To myByte.Length - 1
If myByte(i) <0 Then
strCheck &= Convert.ToChar(myByte(i))
End If
Next

If LCase(strCheck).IndexOf("outlook") -1 Then
Dim myOlApp As New Outlook.ApplicationClass
Dim myExp As Outlook.Explorer = myOlApp.ActiveExplorer
Dim myMailItem As Outlook.MailItem
myMailItem = DirectCast(myExp.Selection.Item(1),
Outlook.MailItem)
RichTextBox1.Text = myMailItem.Body
myExp = Nothing
myMailItem = Nothing
myOlApp = Nothing
End If

End If
End Sub

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"SStory" <no****@nospam.comschreef in bericht
news:uO**************@TK2MSFTNGP06.phx.gbl...
That's a real bummer, because you can drag and drop to the desktop and get
everything it seems in an .msg file.
"Peter Proost" <pp*****@nospam.hotmail.comwrote in message
news:OW**************@TK2MSFTNGP05.phx.gbl...
If you open the message you can just select and drag drop the body to
the
richtextbox like this:

Private Sub RichTextBox1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragEnter
If (e.Data.GetDataPresent(DataFormats.StringFormat)) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub

Private Sub RichTextBox1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragDrop
RichTextBox1.Text =
e.Data.GetData(DataFormats.StringFormat).ToString
End Sub

I don't think it's possible to get the message by only dragging and
dropping
the message header, I think you can only get From, Subject, Received,
and
Size this way

Hope this helps

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to
produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"SStory" <no****@nospam.comschreef in bericht
news:uD**************@TK2MSFTNGP05.phx.gbl...
I want to drag a message from Outlook to a richtextbox on a vb.net
form.
I
don't get the message body. I have searched all over the place and
found
nothing.

Does anyone know how to do this? I don't care about attachments. I
just
need the text.

Thanks,

Shane



Aug 25 '06 #4
Peter,

Thanks for all of your help. I'm glad there is a way to do it. I am;
however, very sorry that it can't be done without automating Outlook. It
would be nice to just grab from the clipboard.

-Shane

"Peter Proost" <pp*****@nospam.hotmail.comwrote in message
news:ux****************@TK2MSFTNGP05.phx.gbl...
After some researching I got a working sample using outlook automation,
you
need a reference to the outlook object library for it to work. It check's
to
see if the "Object Descriptor" contains outlook, the it opens an
outlookapplication class and get's the active explorer selected message,
from this the message body is retrieved.

Hope this helps
Private Sub RichTextBox1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragEnter
If e.Data.GetDataPresent("Object Descriptor") Then
e.Effect = DragDropEffects.Copy
'(0): "RenPrivateSourceFolder"
'(1): "RenPrivateMessages"
'(2): "FileGroupDescriptor"
'(3): "FileContents"
'(4): "Object Descriptor"
'(5): "System.String"
'(6): "UnicodeText"
'(7): "Text"
Else
e.Effect = DragDropEffects.None
End If

End Sub

Private Sub RichTextBox1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragDrop
If (e.Data.GetDataPresent("Object Descriptor")) Then
Dim myMem As New MemoryStream
Dim myByte As Byte()
Dim strCheck As String
myMem = DirectCast(e.Data.GetData("Object Descriptor"),
MemoryStream)
myByte = myMem.ToArray
myMem.Close()
For i As Integer = 0 To myByte.Length - 1
If myByte(i) <0 Then
strCheck &= Convert.ToChar(myByte(i))
End If
Next

If LCase(strCheck).IndexOf("outlook") -1 Then
Dim myOlApp As New Outlook.ApplicationClass
Dim myExp As Outlook.Explorer = myOlApp.ActiveExplorer
Dim myMailItem As Outlook.MailItem
myMailItem = DirectCast(myExp.Selection.Item(1),
Outlook.MailItem)
RichTextBox1.Text = myMailItem.Body
myExp = Nothing
myMailItem = Nothing
myOlApp = Nothing
End If

End If
End Sub

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"SStory" <no****@nospam.comschreef in bericht
news:uO**************@TK2MSFTNGP06.phx.gbl...
>That's a real bummer, because you can drag and drop to the desktop and
get
everything it seems in an .msg file.
"Peter Proost" <pp*****@nospam.hotmail.comwrote in message
news:OW**************@TK2MSFTNGP05.phx.gbl...
If you open the message you can just select and drag drop the body to
the
richtextbox like this:

Private Sub RichTextBox1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragEnter
If (e.Data.GetDataPresent(DataFormats.StringFormat)) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub

Private Sub RichTextBox1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragDrop
RichTextBox1.Text =
e.Data.GetData(DataFormats.StringFormat).ToString
End Sub

I don't think it's possible to get the message by only dragging and
dropping
the message header, I think you can only get From, Subject, Received,
and
Size this way

Hope this helps

Greetz Peter

--
Programming today is a race between software engineers striving to
build
bigger and better idiot-proof programs, and the Universe trying to
produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"SStory" <no****@nospam.comschreef in bericht
news:uD**************@TK2MSFTNGP05.phx.gbl...

I want to drag a message from Outlook to a richtextbox on a vb.net
form.
I
don't get the message body. I have searched all over the place and
found
>nothing.

Does anyone know how to do this? I don't care about attachments. I
just
>need the text.

Thanks,

Shane




Aug 25 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Karsten Schramm | last post by:
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....
0
by: SamSpade | last post by:
Anyone know anything about add Drag-Drop in a RichTextbox. I want to be able to drag (move) some text in the box to a different place in the box Any help at all will be appreciated
1
by: Oleg Medyanik | last post by:
Hi, Is there any way to drag-drop messages from Outlook 2003 into my Application (.NET based) I have not found it googling yet. The problem is that i want the messages to preserve their MSG...
0
by: SamSpade | last post by:
I've been coding for Drag-Drop in a RichTextBox. I want to drag some text in the box to a different place in the box. I've tried a couple of times and each approach has a short coming. Is...
3
by: Thomas | last post by:
Hi all, I've got a half-functioning drag-drop from outlook app running. I can get the name of the message from the FileGroupDescriptor part, but whenever I try to get the FileContents part, I...
0
by: Yavuz Bogazci | last post by:
Hi, how can i drag&drop an Email diretly out of Outlook into an WinForm completely. Thanks Yavuz Bogazci
0
by: SamSpade | last post by:
I've mentioned in other post that I've implemented Drag/Drop for a RichTextBox and using it clears the undo buffer except for the Drag/Drop undo. I'd love to hear from someone that they have...
5
by: Brian Henry | last post by:
I haven't worked much with drag/drop but I am trying to make a form that accepts files to drug onto it from explorer and droped and have the form know the full path and file name of the files...
0
by: Pesso | last post by:
I'm loading a text file to a RichTextBox control to drag a selection of a text and drop it into a tree view control. It works except after the drag and drop operation the RichTextBox scrolls to the...
2
by: =?Utf-8?B?QWxleGFuZGVyIEtvbW1lcg==?= | last post by:
Hi, I´m developing a feature in a application with the following specification: In the first step, the application should be able to store messages out of outlook, which are dropped on a tree...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.