Setting HTMLBody property of a new MailItem

Add-in Express™ Support Service
That's what is more important than anything else

Setting HTMLBody property of a new MailItem
 
Sam Mulholland




Posts: 9
Joined: 2005-03-07
Hi there,

A particular function of the COM add-in I'm working on requires the body property of a new MailItem to be set from code *before* the inspector displays it using the ItemOpen event.

For RichText and Plain messages this works correctly, the body property is set and displays when the new MailItem is displayed. However setting the HTMLBody property to handle HTML messages it does not display!

I believe my code is doing something though. When I close the new MailItem Outlook asks if I want to save any changes, as if the setting of the property was successful. If I 'Design This Form' on the new MailItem then the HTMLBody is shown for some reason.

If I set the HTMLBody property *after* the MailItem is displayed (for example using a command button) it works.

Perhaps this is a display bug with HTML messages in Outlook? Has anyone struck the same problem?

I'm using Outlook 2003 SP1, Delphi 6 Enterprise, Add-In Express VCL 2.2 and Outlook Security Manager 1.0
Posted 07 Mar, 2005 19:27:31 Top
Sam Mulholland




Posts: 9
Joined: 2005-03-07
Don't worry, I found something that works:

If I set the MailItem's Body property to an empty string before making the change to the HTMLBody property it is displayed as intended.

MailItem.Body := '';
MailItem.HTMLBody := '<HTML><BODY>Test</BODY></HTML>';
Posted 07 Mar, 2005 19:47:16 Top