拖放从Outlook的一个或多个邮件到C#WPF应用程序 [英] Drag'n'drop one or more mails from Outlook to C# WPF application

查看:199
本文介绍了拖放从Outlook的一个或多个邮件到C#WPF应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写在WPF使用C#.Net的3.5 SP1,其中一个要求是从电子邮件客户端接收的数据可以存储在数据库中的Windows客户机上。现在处理这个最简单的方法是复制和粘贴文本,主题,联系信息和时间收到使用Ctrl-C / CTRL-V的关节炎诱导金额的。

I'm working on a windows client written in WPF with C# on .Net 3.5 Sp1, where a requirement is that data from emails received by clients can be stored in the database. Right now the easiest way to handle this is to copy and paste the text, subject, contact information and time received manually using an arthritis-inducing amount of ctrl-c/ctrl-v.

我认为,一个简单的方法来处理这将允许用户从Outlook拖动一个或多个电子邮件(它们都使用Outlook 2007当前)到窗口,让我的应用程序中提取必要的信息,并发送它用于存储的后端系统。

I thought that a simple way to handle this would be to allow the user to drag one or more emails from Outlook (they are all using Outlook 2007 currently) into the window, allowing my app to extract the necessary information and send it to the backend system for storage.

然而,几个小时谷歌搜索的信息,这似乎表明了有关这个看似基本任务一个令人震惊的信息缺乏。我想这样的事情将是一个很大的不同的设置是有用的,但我已经能够找到迄今已半生不熟的非解决方案。

However, a few hours googling for information on this seem to indicate a shocking lack of information about this seemingly basic task. I would think that something like this would be useful in a lot of different settings, but all I've been able to find so far have been half-baked non-solutions.

有没有人对如何做到这一点有什么建议?由于我只是要读的邮件,不发送任何东西,或做任何坏事,这将是与不涉及安全讨厌弹出窗口的解决方案不错,但任何不节拍能够做到这一点的。

Does anyone have any advice on how to do this? Since I am just going to read the mails and not send anything out or do anything evil, it would be nice with a solution that didn't involve the hated security pop ups, but anything beats not being able to do it at all.

基本上,如果我能得到中选定的所有邮件项的列表,拖动并从Outlook下降,我就能处理其余部分喽!

Basically, if I could get a list of all the mail items that were selected, dragged and dropped from Outlook, I will be able to handle the rest myself!

谢谢!

符文

推荐答案

我发现了一个伟大文章应该做的正是你需要。

I found a great article that should do exactly what you need to.

更新

我能得到的代码在那篇文章中工作的WPF稍加调整,下面是你需要做出的改变。

I was able to get the code in that article working in WPF with a little tweaking, below are the changes you need to make.

更改为System.Windows.IDataObject从System.Windows.Forms.IDataObject所有引用

Change all references from System.Windows.Forms.IDataObject to System.Windows.IDataObject

在OutlookDataObject构造,改变

In the OutlookDataObject constructor, change

FieldInfo innerDataField = this.underlyingDataObject.GetType().GetField("innerData", BindingFlags.NonPublic | BindingFlags.Instance);

FieldInfo innerDataField = this.underlyingDataObject.GetType().GetField("_innerData", BindingFlags.NonPublic | BindingFlags.Instance);



将所有DataFormats.GetFormat调用DataFormats.GetDataFormat

Change all DataFormats.GetFormat calls to DataFormats.GetDataFormat

更改从

public void SetData(string format, bool autoConvert, object data)
{
    this.underlyingDataObject.SetData(format, autoConvert, data);
}

public void SetData(string format, object data, bool autoConvert)
{
    this.underlyingDataObject.SetData(format, data, autoConvert);
}

通过这些变化,我能得到它保存消息的文件作为文章一样。很抱歉的格式,但编号/项目符号列表不使用代码片断很好地工作。

With those changes, I was able to get it to save the messages to files as the article did. Sorry for the formatting, but numbered/bulleted lists don't work well with code snippets.

这篇关于拖放从Outlook的一个或多个邮件到C#WPF应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆