开发者

Outlook Macro New Message Loses Formatting

开发者 https://www.devze.com 2023-03-29 03:01 出处:网络
I am writing an outlook sub procedure that takes the currently selected email, parses it, and creates a new email message. The parsing is simple enough: Extract the email addresses from the first line

I am writing an outlook sub procedure that takes the currently selected email, parses it, and creates a new email message. The parsing is simple enough: Extract the email addresses from the first line of the message and then the rest of the body is the regular email body in the new message.

I am using this basic code for setting the body of the new message:

Set newMsg = Outlook.Application.CreateItem(olMailItem)
With newMsg
   .BodyFormat = olFormatHTML
   .Body = newBody
   '... set subject,etc
   .Display

The problem is that the new message that is created loses all of the HTML formatting that the message I was copying the information from possessed ( and various font stylings). I tried setting the new message's body format to HTML (see code above), but that 开发者_StackOverflow中文版did not do the trick. Currently, the new message contains all of the textual data, but instead of the table, each cell's data is tab-delimited and the entire message body is in the same font.


BodyFormat does not behave as expected. Instead, HTMLBody can be used as below to properly display the body in HTML format:

With newMsg .HTMLBody = newBody '... set subject,etc .Display

0

精彩评论

暂无评论...
验证码 换一张
取 消