首页 > 解决方案 > 如何使用具有 HTML 正文的 Redemption C# 创建 Outlook .msg 文件?

问题描述

创建 HTML 格式的 .msg 文件时,我似乎无法获得任何格式。文本显示在正文中,但未应用 HTML 格式。有什么建议么?

RDOSession rdoSession = new RDOSession();
rdoSession.Logon();

// Start with a seed.msg
File.Copy(@".\seed.msg", @".\test.msg", true);
RDOMail rdoMail = rdoSession.GetMessageFromMsgFile(@".\test.msg", false);
// Set body format to HTML
rdoMail.BodyFormat = 2;
rdoMail.Subject = "HTML format test";
rdoMail.HTMLBody = "<html><body><b>bold</b> text</body></html>";
// PR_InetMailOverrideFormat  
rdoMail.set_Fields(0x59020003, 0x00020000 | 0x00100000 | 0x00040000);
// PR_MSG_EDITOR_FORMAT
rdoMail.set_Fields(0x59090003, 2);
rdoMail.Save();

标签: outlook-redemption

解决方案


看起来您正在打开一个现有的 MSG 文件。我对从 OutlookSpy 执行的以下脚本没有任何问题(单击 OutlookSpy 工具栏上的“脚本编辑器”按钮,粘贴脚本,单击运行):

set Session = CreateObject("Redemption.RDOSession")
set rdoMail = Session.CreateMessageFromMsgFile("c:\temp\html.msg")
rdoMail.Subject = "HTML format test"
rdoMail.HTMLBody = "<html><body><b>bold</b> text</body></html>"
rdoMail.Save

推荐阅读