Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to drag files from c# winforms app to outlook message

Tags:

c#

outlook

drag

I'm trying to drag one or more files from my application to an outlook mail-message. If I drag to my desktop the files are copied to the desktop as expected, but when dragging into a new outlook 2013 mail message, nothing happens... Only when I drag explicitly to the 'attachments textbox' do they appear, this is not helpful because the attachment-textbox isn't shown by default.

I don't understand why when I drag file(s) from my desktop to the mail I can just drop them and the attachment-text automatically appears showing the files but when I drag from my app it's not working..., here's my code :

'

    private void Form1_MouseDown(object sender, MouseEventArgs e)
    {
        var _files = new string[] { @"E:\Temp\OR_rtftemplates.xml", @"E:\Temp\Tail.Web_Trace.cmd" };
        var fileDragData = new DataObject(DataFormats.FileDrop, _files);

        (sender as Form).DoDragDrop(fileDragData, DragDropEffects.All);

        Console.WriteLine("{0} - button1_MouseDown", DateTime.Now.TimeOfDay);
    }

'

I've also added the files to the DataObject by using the 'SetFileDropList' method but that makes no difference.

The must be some magic property I have to set to get this working right with an outlook-message.

I hope someone can shed some light on this.

thanks, Jurjen.

like image 881
Jurjen Avatar asked Jun 21 '13 09:06

Jurjen


People also ask

Can I move programs from C drive to D?

Move Programs in Apps & Features Or Go to Settings > Click "Apps" to open Apps & features. Step 2. Select the program and click "Move" to continue, then select another hard drive such as D: drive to move the selected app to and click "Move" to confirm.


1 Answers

I just tested some other stuff on a machine running .NET 4.0 (app was compiled in .NET 4.5), after changing .NET target to 4.0 and recompiling it does work, dragging files into a new outlook message, very strange, might be a problem when migrating to .NET 4.5 later... but for now it works...

like image 62
Jurjen Avatar answered Oct 25 '22 12:10

Jurjen