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
outlookapplicat ion class and get's the active explorer selected message,
from this the message body is retrieved.
Hope this helps
Private Sub RichTextBox1_Dr agEnter(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles RichTextBox1.Dr agEnter
If e.Data.GetDataP resent("Object Descriptor") Then
e.Effect = DragDropEffects .Copy
'(0): "RenPrivateSour ceFolder"
'(1): "RenPrivateMess ages"
'(2): "FileGroupDescr iptor"
'(3): "FileConten ts"
'(4): "Object Descriptor"
'(5): "System.Str ing"
'(6): "UnicodeTex t"
'(7): "Text"
Else
e.Effect = DragDropEffects .None
End If
End Sub
Private Sub RichTextBox1_Dr agDrop(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles RichTextBox1.Dr agDrop
If (e.Data.GetData Present("Object Descriptor")) Then
Dim myMem As New MemoryStream
Dim myByte As Byte()
Dim strCheck As String
myMem = DirectCast(e.Da ta.GetData("Obj ect 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("outlo ok") -1 Then
Dim myOlApp As New Outlook.Applica tionClass
Dim myExp As Outlook.Explore r = myOlApp.ActiveE xplorer
Dim myMailItem As Outlook.MailIte m
myMailItem = DirectCast(myEx p.Selection.Ite m(1),
Outlook.MailIte m)
RichTextBox1.Te xt = 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******** ******@TK2MSFTN GP06.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.comwro te in message
news:OW******** ******@TK2MSFTN GP05.phx.gbl...
If you open the message you can just select and drag drop the body to
the
richtextbox like this:
Private Sub RichTextBox1_Dr agEnter(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles RichTextBox1.Dr agEnter
If (e.Data.GetData Present(DataFor mats.StringForm at)) Then
e.Effect = DragDropEffects .Copy
Else
e.Effect = DragDropEffects .None
End If
End Sub
Private Sub RichTextBox1_Dr agDrop(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles RichTextBox1.Dr agDrop
RichTextBox1.Te xt =
e.Data.GetData( DataFormats.Str ingFormat).ToSt ring
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******** ******@TK2MSFTN GP05.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