如何将文件从C#WinForms应用程序拖动到Outlook消息 [英] How to drag files from c# winforms app to outlook message
问题描述
我正在尝试将一个或多个文件从我的应用程序拖到Outlook邮件消息中. 如果我将鼠标拖到桌面上,文件将按预期复制到桌面上,但是当拖到新的Outlook 2013邮件中时,什么也不会发生...仅当我显式拖到附件文本框"时,它们才会出现有用,因为默认情况下不显示附件文本框.
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);
}
'
我还使用'SetFileDropList'方法将文件添加到了DataObject中,但这没什么区别.
I've also added the files to the DataObject by using the 'SetFileDropList' method but that makes no difference.
必须具有一些神奇的属性,我才能通过Outlook消息使它正常工作.
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.
谢谢, 茹仁.
推荐答案
在将.NET target更改为4.0并重新编译之后,我刚刚在运行.NET 4.0的计算机(应用程序在.NET 4.5中进行了编译)上测试了其他内容.确实可以正常工作,将文件拖到新的Outlook消息中,这很奇怪,以后再迁移到.NET 4.5时可能会出现问题...但是目前可以正常工作...
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...
这篇关于如何将文件从C#WinForms应用程序拖动到Outlook消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!