gpt4 book ai didi

c# - 从剪贴板获取复制的电子邮件

转载 作者:行者123 更新时间:2023-11-30 16:49:55 27 4
gpt4 key购买 nike

我有一个显示目录内容的 ListView 。我启用了拖放到 ListView 中,以便用户可以将文件从Windows 资源管理器并将其放入 ListView 中。然后,我将这些文件复制到 ListView 中显示的目录中。

如果您将电子邮件从 Outlook 拖到桌面或 Windows 资源管理器中的文件夹中,它会创建电子邮件的 .msg 文件。用户现在想从 outlook 中拖动电子邮件并将它们放入 ListView 中。

当电子邮件在 ListView 上是毒品时,它不会将其视为有效的拖放对象。光标是一个带有一条线的圆圈,而不是放置事件光标。

listView1_DragEnter 事件中我有

        if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.All;
}
else
{
e.Effect = DragDropEffects.None;
}

我已经尝试过 DataFormats.HTML 但也看不到任何可删除的内容。有什么想法吗?

电子邮件是从 Outlook 的列表部分拖出的。
enter image description here

最佳答案

在 ListView 的DragEnter 事件中,返回以下DragDropEffects:

private void listView_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}

要在 DragDrop 事件中提取和阅读 Outlook 消息,我建议使用 this图书馆。它非常易于使用:

private void listView_DragDrop(object sender, DragEventArgs e)
{
OutlookDataObject dataObject = new OutlookDataObject(e.Data);

//get the names and data streams of the files dropped
string[] filenames = (string[])dataObject.GetData("FileGroupDescriptor");
MemoryStream[] filestreams = (MemoryStream[])dataObject.GetData("FileContents");

for (int fileIndex = 0; fileIndex < filenames.Length; fileIndex++)
{
string filename = filenames[fileIndex];
MemoryStream filestream = filestreams[fileIndex];

OutlookStorage.Message message = new OutlookStorage.Message(filestream);

// do whatever you want with "message"

message.Dispose();
}
}

关于c# - 从剪贴板获取复制的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35781068/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com