This documentation is archived and is not being maintained.

AutoGenerateTextBody Property

Exchange Server 2003

AutoGenerateTextBody Property

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

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

Applies To

Type Library

Microsoft CDO for Exchange 2000 Library

DLL Implemented In



        [Visual Basic]Property AutoGenerateTextBody As Boolean
        [C++]HRESULT get_AutoGenerateTextBody(VARIANT_BOOLpVal);
HRESULT put_AutoGenerateTextBody(VARIANT_BOOL Val);


Returns the value of the AutoGenerateTextBody property as a reference to a VARIANT_BOOL.
Sets the value of the AutoGenerateTextBody property to the value of the VARIANT_BOOL.


If the AutoGenerateTextBody property is True (VARIANT_TRUE), the contents of the TextBody property are replaced by the plain text equivalent of the HTMLBody property; that is, the TextBody is the HTMLBody content with all HTML markup removed.

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

  • Setting HTMLBody causes TextBody to be set immediately.
  • Setting TextBody causes AutoGenerateTextBody to be set to False. Any existing HTML content is not updated.
  • Setting HTMLBody causes MimeFormatted to be set to True.
  • Setting MimeFormatted to False causes AutoGenerateTextBody to be set to False.

When using the AutoGenerateTextBody functionality, always update the HTML version of the message body. Updating the plain text version will not cause new HTML to be generated.

For messages that contain other alternate representations besides HTML and plain text, you must create or update each individually.

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


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]

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 = ""
  .From = ""
  .Subject = "Sample multipart/alternative message"
  .HTMLBody = strHTML ' .TextBody gets generated automatically
End With


 You must have the following paths in your
 INCLUDE path.
 %CommonProgramFiles%\microsoft shared\cdo

#import <msado15.dll> no_namespace
#import <cdoex.dll> no_namespace
#include <iostream.h>

void IMessage_AutoGenerateTextBody_Example() {

   try {
      IMessagePtr iMsg(__uuidof(Message));
      _bstr_t html   = "<HTML><h1>Hello There</h1></HTML>";
      iMsg->To       = "" ;
      iMsg->From     = "" ;
      iMsg->Subject  = "Sample multipart/alternative message" ;
      iMsg->HTMLBody = html;
      iMsg = NULL;

   catch(_com_error e) {
      throw e;