Hi guys,

I'm working on an application that uses a DragDrop function to allow the user to drop files onto my form. This works fine when I'm working with normal files, documents and such. But I need it to work when the user drags an e-mail from Outlook onto the form too.

So far I've tried using the FileDrop format for this, which didn't work. I then found that the data has about 10-13 formats when I use the IDataObject.GetFormats method. It seems I need to somehow read some data from a memorystream which is contained in the IDataObject.
I hope this is understandable.

What I need is the path (local or UNC) to the .msg file that the user is dropping on my form. This is my current code:

Code:
//IDataObject data is taken in as a parameter
string[] formats = data.GetFormats(true);
bool done = false;
for (int i = 0; i < formats.Length && !done; i++)
{
    try
    {
        object o = data.GetData(formats[i]);
        if (o.GetType() == typeof(System.IO.MemoryStream))
        {
            byte[] buffer = new byte[((MemoryStream)o).Length];

            ((MemoryStream)o).Read(buffer, 0, buffer.Length);
            path = Encoding.UTF8.GetString(buffer);
            if (!File.Exists(path))
                path = null;
        }
        if (path != null)
            done = true;
    }
    catch { }
}
When I debug I can see that some of the objects I get out contains the details of the .msg file, but none contain the path.
The byte[] mostly contains all zeros, but some of them seem to actually contain data (not surprising), but I don't know how to read it.

I know this is probably a poor attempt, but I had to start somewhere Any help will be greatly appreciated