gpt4 book ai didi

c# - 在 ASP.Net MVC 应用程序中创建 Outlook 模板 (.oft) 文件

转载 作者:太空狗 更新时间:2023-10-29 23:44:17 25 4
gpt4 key购买 nike

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

最佳答案

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

因为 MSG 文件格式是 documented ,您可以创建 CLSID 为 {0006F046-0000-0000-C000-000000000046} 的 MSG 文件,而不是 {00020D0B-0000-0000-C000-000000000046}。

您还可以使用 Redemption (我是它的作者)-它的RDO family of objects可以在服务中使用,你只需要确保安装了匹配位数的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);

关于c# - 在 ASP.Net MVC 应用程序中创建 Outlook 模板 (.oft) 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34876552/

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