简体   繁体   English

将邮件从Outlook拖放到文本

[英]Drag and drop mail from Outlook to text

This is a bit of a soft question, as I haven't really gotten to the point where I have started coding my project yet. 这是一个软问题,因为我还没有真正开始编写项目代码。 What I'm looking for here are guidelines and recommendations as how best to build my desired software. 我在这里寻找的是有关如何最好地构建所需软件的指南和建议。

I've always been fascinated with drag and drop technology, and Outlook let's me drag an email to my desktop (in Windows) without a problem. 我一直对拖放技术着迷,Outlook让我毫无问题地将电子邮件拖到桌面(在Windows中)。

I wish to be able to continue to do this, but when dragged and dropped, I want the email on my desktop to be in .txt format, and be filled with the content of the email. 我希望能够继续执行此操作,但是在拖放时,我希望桌面上的电子邮件为.txt格式,并填充其中的电子邮件内容。

Now, the following is a little free thinking as to what I have going in my head thus far. 现在,以下是一些关于我到目前为止的想法的自由思考。

In order to drag an email out of Outlook it has to be selected, so I am thinking I can obtain the selected email through the following in C# . 为了将电子邮件拖出Outlook,必须先选择它,所以我想我可以通过C#的以下命令获取选择的电子邮件。

Firstly using: 首先使用:

using Office = Microsoft.Office.Core; 
using Outlook = Microsoft.Office.Interop.Outlook;

Then getting the currently selected email by: 然后通过以下方式获取当前选择的电子邮件:

Outlook.Selection currentSelection = control.Context as Outlook.Selection;
Outlook.MailItem selectedMail = currentSelection[1];

Now, the way I see it, the content from the email needs to be obtained when the dragging begins, and result in a new .txt file when the drop happens, containing for example the message body text. 现在,按照我的观察方式,需要在拖动开始时从电子邮件中获取内容,并在发生拖放时生成一个新的.txt文件,其中包含例如邮件正文文本。

But that's just me thinking aloud. 但这只是我大声思考。

How would some of you guys go about it? 你们中的一些人会如何做呢?

Is there some way to specify an event occurrence when an element in Outlook is dragged? 在拖动Outlook中的元素时,是否有某种方法可以指定事件发生?

And if so, can I specify what happens to the processed information when it drops? 如果是这样,我可以指定处理后的信息掉落时会发生什么情况吗? Like pasting it into a new .txt file at the desired location? 是否要将其粘贴到新的.txt文件中所需的位置?

Or am I thinking about this all wrong? 还是我在想这一切错了?

You can use the Selection object when you drag and drop Outlook items to any forms. 将Outlook项目拖放到任何窗体中时,可以使用Selection对象。 So, if the item is dropped there you can get it via the Selection object in Outlook. 因此,如果将该项目放到那里,则可以通过Outlook中的Selection对象获得它。 But when you Drga&Drop Outlook items on the desktop (to any folder on the disk) you get a .msg file. 但是,当您在桌面上Drga&Drop Outlook项目(到磁盘上的任何文件夹)时,您将获得一个.msg文件。 There is no trivial way to override that behaviour. 没有任何简单的方法可以覆盖该行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM