Platform SDK: CDO for Windows 2000

Setting the HTML Message Body

In addition to a plain text body, you can use text formatted in Hypertext Markup Language (HTML) using the IMessage.HTMLBody property. By default, the IMessage.AutoGenerateTextBody property in the object is set to True (VARIANT_TRUE); therefore, a plain text body is automatically generated from the HTML body text to support recipients whose e-mail client cannot display messages formatted in HTML. For more information on creating attachments, see Creating MIME Formatted Messages.

[Visual Basic]
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Windows 2000 Library
Dim iMsg as New CDO.Message

With iMsg
  .To   = "someone@microsoft.com"
  .Newsgroups = "comp.microsoft.newsgroup1"
  .Subject  = "Agenda for staff meeting"
  .HTMLBody = "<html><body><p>Please plan to present your status for the following projects...</p></body></html>"
End With
[C++,IDL]
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace
#import <cdosys.dll> no_namespace
// ...
IMessagePtr iMsg(__uuidof(Message));

iMsg->To         = "someone@microsoft.com";
iMsg->Newsgroups = "comp.microsoft.newsgroup1";
iMsg->Subject    = "Agenda for staff meeting";
iMsg->HTMLBody   = "<html><body><p>Please plan to present your status for the following projects...</p></body></html>";
[VBScript]
Dim iMsg 
Set iMsg = CreateObject("CDO.Message")

With iMsg
  .To         = "someone@microsoft.com"
  .Newsgroups = "comp.microsoft.newsgroup1"
  .Subject    = "Agenda for staff meeting"
  .HTMLBody   = "<html><body><p>Please plan to present your status for the following projects...</p></body></html>"
End With

See Also

IMessage.Subject

IMessage.TextBody

IMessage.HTMLBody

IMessage.AutoGenerateTextBody

Creating MIME Formatted Messages