Share via

AutoGenerateTextBody Property

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

IMessage Interface

IWorkflowMessage Interface

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);


  • pVal
    Returns the value of the AutoGenerateTextBody property as a reference to a VARIANT_BOOL.
  • Val
    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 .Send End With


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

*/ #ifndef _CORE_EXAMPLE_HEADERS_INCLUDED #define _CORE_EXAMPLE_HEADERS_INCLUDED #import <msado15.dll> no_namespace #import <cdoex.dll> no_namespace #include <iostream.h> #endif

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->Send(); iMsg = NULL;

} catch(_com_error e) { throw e; } }

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.