AutoGenerateTextBody Property
Topic Last Modified: 2006-12-01
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
CDOEX.DLL
Syntax
Property AutoGenerateTextBody As Boolean
HRESULT get_AutoGenerateTextBody(VARIANT_BOOL* pVal);HRESULT put_AutoGenerateTextBody(VARIANT_BOOL Val);
Parameters
- 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.
Remarks
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.
Examples
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:
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@example.com"
.From = "another@example.com"
.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 = "Somebody@example.com" ;
iMsg->From = "another@example.com" ;
iMsg->Subject = "Sample multipart/alternative message" ;
iMsg->HTMLBody = html;
iMsg->Send();
iMsg = NULL;
}
catch(_com_error e) {
throw e;
}
}