5

我需要在 ASP.Net MVC4 Web 应用程序(使用 C#)中将 html 模板下载为 OFT 文件。我已经尝试过 Microsoft.Office.Interop.Outlook,它在我的本地机器上运行良好,但在服务器上运行失败。它需要在服务器中安装 Outlook,而且我还听说在服务器中为 Web 应用程序自动化 MS Office 应用程序并不是一个好习惯。是否可以在不使用 MS Office Outlook 的情况下创建一个经常文件?有没有免费的图书馆可以做到这一点?任何人都知道解决方案,请帮助。

4

1 回答 1

1

OFT 文件是具有不同类 GUID 的 MSG 文件。MSG 文件是一个 OLE 存储 (IStorage) 文件。

由于记录了 MSG文件格式,因此您可以创建一个 CLSID 为 {0006F046-0000-0000-C000-000000000046} 而不是 {00020D0B-0000-0000-C000-000000000046} 的 MSG 文件。

您也可以使用Redemption - 它的RDO 系列对象可以在服务中使用,您只需要确保安装了具有匹配位数的 Outlook(Redemption 使用 Outlook 安装的 MAPI 系统,而不是 Outlook 对象模型,它不能在服务中使用)。

VB脚本:

  set Session = CreateObject("Redemption.RDOSession")
  set Msg = Session.CreateMessageFromMsgFile("c:\Temp\TestMsg.msg")
  Msg.Body = "This is a test template"
  Msg.Subject = "Template"
  Msg.Save
  Msg.SaveAs "c:\Temp\TestTemplate.oft", olTemplate

C#(在我脑海中浮现):

  Redemption.RDOSession rSession = new Redemption.RDOSession();
  Redemption.RDOMail Msg = rSession.CreateMessageFromMsgFile("c:\Temp\TestMsg.msg");
  Msg.Body = "This is a test template";
  Msg.Subject = "Template";
  Msg.Save();
  Msg.SaveAs("c:\Temp\TestTemplate.oft", Redemption.rdoSaveAsType.olTemplate);
于 2016-01-20T22:43:47.290 回答