'How to create an Outlook .msg file with Redemption C# that has an HTML body?

I can't seem to get any formatting when creating a HTML format .msg file. The text shows up in the body but the HTML formatting is not applied. Any suggestions?

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();


Solution 1:[1]

It looks like you are opening an existing MSG file instead of creating a new one. I had no problem with the following script executed from OutlookSpy (I am its author) - click “Script Editor” button on the OutlookSpy toolbar, paste the script, click Run:

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1