all groups > vb.net controls > february 2004 >
You're in the

vb.net controls

group:

Drag and drop from outlook


Drag and drop from outlook PromisedOyster NO[at]SPAM hotmail.com
2/29/2004 4:19:54 AM
vb.net controls:
Does anyone have code samples of how to drag and drop emails in
Outlook onto a windows form???

I see that there are a number of threads that raise this issue but
Re: Drag and drop from outlook PromisedOyster NO[at]SPAM hotmail.com
3/2/2004 3:29:08 AM
Thanks Norton.

I can get that much to work OK, but what I really want is to get the
MSG file.

eg (sorry its in csharp)

private void Form1_DragEnter(object sender,
System.Windows.Forms.DragEventArgs e)
{
string []formats= e.Data.GetFormats(); // works ok
string text = (string)e.Data.GetData("Text"); // works ok

Outlook.MailItem mi =
(Outlook.MailItem)e.Data.GetData("FileContents"); // sets to null
string mis = (string)e.Data.GetData("FileContents"); // sets to null
}

How the heck can I use GetData to return an MSG file????


[quoted text, click to view]
Re: Drag and drop from outlook Norton
3/2/2004 10:18:57 AM
I set the textbox property allowdrop to true
then do it as normals(without checking the drag source)

Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As =
System.Windows.Forms.DragEventArgs) Handles TextBox1.DragDrop
TextBox1.Text =3D e.Data.GetData(DataFormats.UnicodeText, True)

End Sub
Private Sub TextBox1_DragEnter(ByVal sender As Object, ByVal e As =
System.Windows.Forms.DragEventArgs) Handles TextBox1.DragEnter
e.Effect =3D DragDropEffects.Copy
End Sub

If u want to determinate the data format, u can ise getformats method=20
Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As =
System.Windows.Forms.DragEventArgs) Handles TextBox1.DragDrop
'TextBox1.Text =3D e.Data.GetData(DataFormats.Text).ToString
Dim mytext As New System.Text.StringBuilder
Dim i As Integer
Dim data() As String
data =3D e.Data.GetFormats(True)
For i =3D 0 To UBound(data)
mytext.Append("Item " & i & ": " & Chr(9))
mytext.Append(data(i))
mytext.Append(Environment.NewLine)
Next
TextBox1.Text =3D mytext.ToString
End Sub

Hope it helps

[quoted text, click to view]
AddThis Social Bookmark Button