473,383 Members | 2,005 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,383 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 14548
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.