Platform SDK: CDO for Windows 2000

AutoGenerateTextBody Property

The AutoGenerateTextBody property indicates whether the TextBody property of a message should automatically be generated from the contents of the HTMLBody property for a multipart/alternative message.

[Visual Basic]
Property AutoGenerateTextBody as Boolean
[C++]
HRESULT get_AutoGenerateTextBody(VARIANT_BOOL* pVal);
HRESULT put_AutoGenerateTextBody(VARIANT_BOOL Val);
[IDL]
HRESULT [propget] AutoGenerateTextBody([out,retval] VARIANT_BOOL* pVal);
HRESULT [propput] AutoGenerateTextBody([in] VARIANT_BOOL Val);

Remarks

If the AutoGenerateTextBody property is set to True (VARIANT_TRUE), the contents of the TextBody property are replaced by the plain text equivalent of the HTMLBody property; that is, the contents with all Hypertext Markup Language (HTML) tags removed.

The following rules apply to the AutoGenerateTextBody property if it is set to True:

The default value of the AutoGenerateTextBody property is True (VARIANT_TRUE) on newly created messages and False (VARIANT_FALSE) on previously existing messages.

Example

This code takes advantage of the default settings of the AutoGenerateTextBody and IMessage.MimeFormatted properties to send a message with both plain text and HTML versions of the same text:

[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 
Dim strHTML as String
strHTML  = "<HTML><h1>Hello There</h1></HTML>"
Set iMsg = New CDO.Message
With iMsg
  .To      = "Somebody@microsoft.com"
  .From    = "another@microsoft.com"
  .Subject = "Sample multipart/alternative message" 
  .HTMLBody = strHTML ' .TextBody gets generated automatically 
  .Send
End With
[C++,IDL]
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace
#import "c:\\winnt\\system32\\cdosys.dll" no_namespace
#include <cdosysstr.h>
#include <cdosyserr.h>
void main() {
 CoInitialize(NULL);
 {
   IMessagePtr iMsg(__uuidof(Message));
   _bstr_t html   = "<HTML><h1>Hello There</h1></HTML>";
   iMsg->To       = "Somebody@microsoft.com" ; 
   iMsg->From     = "another@microsoft.com" ;
   iMsg->Subject  = "Sample multipart/alternative message" ;
   iMsg->HTMLBody = strHTML;
   iMsg->Send();
  }
  CoUninitialize();
}
[VBScript]
Dim iMsg
Set iMsg = CreateObject("CDO.Message")
Dim strHTML
strHTML  = "<HTML><h1>Hello There</h1></HTML>"
With iMsg
  .To      = "Somebody@microsoft.com"
  .From    = "another@microsoft.com"
  .Subject = "Sample multipart/alternative message" 
  .HTMLBody = strHTML ' .TextBody gets generated automatically 
  .Send
End With