Drag and Drop an attachment from an Outlook message

  • Thread starter Thread starter Roy Chastain
  • Start date Start date
R

Roy Chastain

I have an email that has a file attached to it.

If I save the file and drag the file from Windows Explorer to my form, I get a DragDrop event with data type of FileDrop.

If I drag the file directly from the opened email, I get a DragDrop event with the data type of TEXT. What is worse, it appears
to be a empty text string.

The file in question is a .xml and fairly small, so I would even be happy if I could just get the contents of the file as text.

Should I be able to receive that file directly from Outlook email and if so, how.

Thanks
 
Hi Roy,

Thanks for your post.

Actually, this is a frequently asked question, we can get the file
description with the code snippet below:
private void Form1_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)
{
MemoryStream ms;
ms=(MemoryStream)e.Data.GetData("FileGroupDescriptor");
if (ms.Length==0)
{
MessageBox.Show("null ms");
return;
}

ms.Read(new byte[76],0,76);
StringBuilder sb=new StringBuilder();
char aChar=(char)ms.ReadByte();

int i=1;
while (aChar != 0x00)
{
sb.Append(aChar);
aChar=(char)ms.ReadByte();
i++;
}
MessageBox.Show(sb.ToString(),"the attachement file's name is:");
}
However, there is no way for us to get the file content, because the .MSG
file format is not documented from Microsoft. For more information, please
refer to reply original reply:
http://groups.google.com/group/microsoft.public.dotnet.framework.windowsform
s/browse_thread/thread/f760a363c916c7c4/d9ecaa5cba07874f?lnk=st&q=outlook+dr
ag+drop+windowsforms+FileContents&rnum=8&hl=zh-CN#d9ecaa5cba07874f

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top