473,545 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 14572
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


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.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



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
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



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.comwro te in message
news:ux******** ********@TK2MSF TNGP05.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
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******* *******@TK2MSFT NGP05.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




Aug 25 '06 #5

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

Similar topics

1
7604
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. In the "drop event" are eight DataFormats (e.Data.GetFormats()) but the important one (imho) "FileContents" is "Nothing"/"null".
0
316
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
1898
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 format, not just get their text. (it should look like you've dropped message to MS Word). Any help is appreciated. Thanks you
0
1218
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 there any code anywhere that shows a good routine for the drop event? Thanks in advance
3
3510
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 allways get Nothing back. I've posted my code below - I hope someone here has a solution to this. Cheers Thomas Private Sub Label1_DragDrop(ByVal...
0
1213
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
1143
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 experienced the same thing or that their implementation does not clear the buffer. Now for the reason for this post: I've noticed in the...
5
10143
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 dropped onto it.. does anyone have any examples of this? thanks
0
1767
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 top. This is very inconvenient because after the drag-drop operation the user has to scroll down to where he was before. Is there anyway to make...
2
2777
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 view. This message should be stored as ..msg file. In future, this should be able for alle objects of outlook. If a drop a message out of...
0
7659
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7811
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7760
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5975
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4949
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3455
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1887
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
709
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.