问题
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.
回答1:
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...
来源:https://stackoverflow.com/questions/17232446/how-to-drag-files-from-c-sharp-winforms-app-to-outlook-message