MimeComposeMessage
HMESSAGE MimeComposeMessage(
LPCTSTR lpszFrom,  
LPCTSTR lpszTo,  
LPCTSTR lpszCc,  
LPCTSTR lpszSubject,  
LPCTSTR lpszMessageText,  
LPCTSTR lpszMessageHTML,  
UINT nCharacterSet,  
UINT nEncodingType  
);

The MimeComposeMessage function creates a new message using the specified parameters.

Parameters

lpszFrom
A pointer to a null-terminated string which specifies the sender's email address. This parameter may be NULL, in which case no sender address will be included in the message header.
lpszTo
A pointer to a null-terminated string which specifies one or more recipient addresses. If multiple addresses are specified, each address must be separated by a comma. This parameter may be NULL, in which case no recipient addresses will be included in the message header.
lpszCc
A pointer to a null-terminated string which specifies one or more addresses that will receive a copy of the message in addition to the listed recipients. If multiple addresses are specified, each address must be separated by a comma. This parameter may be NULL, in which case no carbon-copy addresses will be included in the message header.
lpszSubject
A pointer to a null-terminated string which specifies the subject of the message. This parameter may be NULL, in which case no subject will be included in the message.
lpszMessageText
A pointer to a null-terminated string which contains the body of the message as plain text. Each line of text contained in the string should be terminated with a carriage-return/linefeed (CRLF) pair, which is recognized as the end-of-line. If this parameter is NULL or points to an empty string, then the message will have an empty body unless the lpszMessageHTML parameter is not NULL.
lpszMessageHTML
A pointer to a null-terminated string which contains the message using HTML formatting. If the lpszMessageText parameter is not NULL, then a multipart message will be created with both plain text and HTML text as the alternative. This allows mail clients to select which message body they wish to display. If the lpszMessageText argument is NULL or points to an empty string, then the message will only contain HTML. Although this is supported, it is not recommended because older mail clients may be unable to display the message correctly.
nCharacterSet
A numeric identifier which specifies the character set to use when composing the message. A value of zero specifies that the default USASCII character set should be used. The following values may also be used:
Constant Description
MIME_CHARSET_USASCII The default character set using US-ASCII which defines 7-bit printable characters with values ranging from 20h to 7Eh.
MIME_CHARSET_ISO8859_1 An 8-bit character set for most western European languages such as English, French, Spanish and German. This character set is also commonly referred to as Latin1.
MIME_CHARSET_ISO8859_2 An 8-bit character set for most central and eastern European languages such as Czech, Hungarian, Polish and Romanian. This character set is also commonly referred to as Latin2.
MIME_CHARSET_ISO8859_5 An 8-bit character set for Cyrillic languages such as Russian, Bulgarian and Serbian.
MIME_CHARSET_ISO8859_6 An 8-bit character set for Arabic languages. Note that the application is responsible for displaying text that uses this character set. In particular, any display engine needs to be able to handle the reverse writing direction and analyze the context of the message to correctly combine the glyphs.
MIME_CHARSET_ISO8859_7 An 8-bit character set for the Greek language.
MIME_CHARSET_ISO8859_8 An 8-bit character set for the Hebrew language. Note that similar to Arabic, Hebrew uses a reverse writing direction. An application which displays this character should be capable of processing bi-directional text where a single message may include both right-to-left and left-to-right languages, such as Hebrew and English.
MIME_CHARSET_ISO8859_9 An 8-bit character set for the Turkish language. This character set is also commonly referred to as Latin5.
nEncodingType
A numeric identifier which specifies the encoding type to use when composing the message. A value of zero specifies that default 7bit encoding should be used. The following values may also be used:
Constant Description
MIME_ENCODING_7BIT Each character is encoded in one or more bytes, with each byte being 8 bits long, with the first bit cleared. This encoding is most commonly used with plain text using the US-ASCII character set, where each character is represented by a single byte in the range of 20h to 7Eh. Most e-mail messages are composed using 7-bit ASCII.
MIME_ENCODING_8BIT Each character is encoded in one or more bytes, with each byte being 8 bits long and all bits are used. 8-bit encoding may be used with multi-byte character sets, although this encoding type is uncommon in e-mail messages. It is recommended that quoted-printable encoding be used for 8-bit character sets.
MIME_ENCODING_QUOTED Quoted-printable encoding is designed for textual messages where most of the characters are represented by the ASCII character set and is generally human-readable. Non-printable characters or 8-bit characters with the high bit set are encoded as hexadecimal values and represented as 7-bit text. Quoted-printable encoding is typically used for messages which use character sets such as ISO-8859-1, as well as those which use HTML.

Return Value

If the function succeeds, the return value is a handle to the message. If the function fails, the return value is INVALID_MESSAGE. To get extended error information, call MimeGetLastError.

Remarks

The MimeComposeMessage function composes a new message and returns a handle which can be used to further modify or export the message. To create an empty message without any predefined header values, call the MimeCreateMessage function.

When the message is not longer needed, the copy of the message in memory should be deleted by calling the MimeDeleteMessage function. This will release the handle and free the memory allocated by this function.

Requirements

Client: Requires Windows Vista, Windows XP or Windows 2000 Professional.
Server: Requires Windows Server 2008, Windows Server 2003 or Windows 2000 Server.
Header: Include cstools6.h.
Library: Use csmsgav6.lib.
Unicode: Implemented as Unicode and ANSI versions.

See Also

MimeCreateMessage, MimeCreateMessagePart, MimeDeleteMessage, MimeExportMessage, MimeImportMessage, MimeInitialize


Copyright © 2008 Catalyst Development Corporation. All rights reserved.