C#:将选定的 Outlook 消息另存为 eml 文件 [英] C#: Save selected outlook message as eml file

查看:37
本文介绍了C#:将选定的 Outlook 消息另存为 eml 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 c# 为 Outlook 创建了一个附加组件.建议连接到外部文件管理系统(DMS)并将文件/电子邮件上传到其中.现在我想通过单击插件中的按钮将 Outlook 窗口中的选定消息保存/发送到 DMS(见上图).有什么正确的方法可以直接做到吗?如果不是,请提供其他方法.

I created an add-on for outlook using c#. It is proposed to connect to external Document Management System(DMS) and upload documents/emails into it. And now I want to save/send selected message from outlook window into DMS by clicking a button from plugin (see picture above). Is there any proper way to do it diractly? If no, please provide the methods to do it in alternative way.

下面是我的按钮和消息的示例

below is an example how my button and message looks like

推荐答案

Outlook 对象模型不支持以 EML (MIME) 格式保存消息.

Outlook Object Model does not support saving messages in the EML (MIME) format.

你可以

1) 在您的代码中显式创建 MIME 文件,一次一个属性.您还可以使用现有的 MIME 转换器(我过去使用 Lumisoft) - 但它们不会在一次调用中转换 Outlook 消息;您将需要显式构建所有标头和 MIME 部分.

1) Create MIME file explicitly in your code one property at a time. You can also use existing MIME converters (I used Lumisoft in the past) - but they won't convert Outlook messages in a single call; you will need to explicitly build all the headers and MIME parts.

2) 使用 IConverterSession 对象(仅限 C++ 或 Delphi) - 这与 Outlook 使用的 MIME 转换器相同.您可以在 OutlookSpy(单击 IConverterSession 按钮)中使用它.

2) Use IConverterSession object (C++ or Delphi only) - this is the same MIME converter used by Outlook. You can play with it in OutlookSpy (click IConverterSession button).

3) 使用Redemption 及其RDOMail.SaveAsSafeMailItem.SaveAs 方法 - 它可以保存为 MIME 格式 (olRfc822) 以及十几种其他格式.它使用 IConverterSession 对象,当它可用(Outlook 2003 及更高版本)或它自己的转换器用于旧版本的 Outlook 或用于 MAPI 的 Exchange 版本.以下脚本会将当前选择的消息保存为 EML 文件.

3) Use Redemption and its RDOMail.SaveAs or SafeMailItem.SaveAs methods - it can save in the MIME format (olRfc822) along with a dozen or so other formats. It uses IConverterSession object when it is available (Outlook 2003 and up) or its own converter for an older version of Outlook or when used against the Exchange version of MAPI. The following script will save the currently selected message as an EML file.

  set Session = CreateObject("Redemption.RDOSession")
  Session.MAPIOBJECT = Application.Session.MAPIOBJECT
  set rItem = Session.GetMessageFromID(Application.ActiveExplorer.Selection(1).EntryID)
  rItem.SaveAs "c:\temp\test.eml", 1024

这篇关于C#:将选定的 Outlook 消息另存为 eml 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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