CreatePart Method  
 

Create a new message part in a multipart message.

Syntax

object.CreatePart( [MessageText], [CharacterSet], [EncodingType])

Parameters

MessageText
An optional string that specifies the body of the new message part. 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 the parameter is not specified, then the message part will have an empty body.
CharacterSet
An optional integer value that specifies the character set that will be used for this message part. If this parameter is omitted, the message part will use the standard UTF-8 character set. This parameter may be one of the following values:
Value Constant Description
1 mailCharsetUSASCII A character set using US-ASCII which defines 7-bit printable characters with values ranging from 20h to 7Eh. An application that uses this character set has the broadest compatibility with most mail servers (MTAs) because it does not require the server to handle 8-bit characters correctly when the message is delivered. This is the most commonly used character set for plain text email messages in the English language.
2 mailCharsetISO8859_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. The Windows code page for this character set is 28591, however Windows code page 1252 (Windows-1252) is typically used to represent this character set in most applications.
3 mailCharsetISO8859_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. This character set is similar to Windows code page 1250, however the characters are arranged differently.
4 mailCharsetISO8859_5 An 8-bit character set for Cyrillic languages such as Russian, Bulgarian and Serbian. The Windows code page for this character set is 28595. This character set is not widely used and it is recommended that you use UTF-8 instead.
5 mailCharsetISO8859_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. This character set is not widely used and it is recommended that you use UTF-8 instead.
6 mailCharsetISO8859_7 An 8-bit character set for the Greek language. This character set is also commonly referred to as Latin/Greek. The Windows code page for this character set is 28597.
7 mailCharsetISO8859_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. The Windows code page for this character set is 28598.
8 mailCharsetISO8859_9 An 8-bit character set for the Turkish language. This character set is also commonly referred to as Latin5. The Windows code page for this character set is 28599.
9 mailCharsetUTF7 A 7-bit Unicode Transformation Format that uses variable-length character encoding to represent Unicode text as a stream of ASCII characters that are safe to transport between mail servers that only support 7-bit printable characters. It is primarily used as an alternative to UTF-8 which requires that the mail server support 8-bit text or use quoted-printable encoding.
10 mailCharsetUTF8 An 8-bit Unicode Transformation Format that uses multi-byte character sequences to represent Unicode text. It is backwards compatible with the ASCII character set, however because it uses 8-bit text, it should be encoded using either quoted-printable or base64 encoding to ensure that mail servers that do not support 8-bit characters.
EncodingType
An optional integer value which specifies the encoding for this message part. If this parameter is omitted, the message part will use standard 7-bit encoding. This parameter may be one of the following values:
Value Constant Description
1 mailEncoding7Bit 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.
2 mailEncoding8Bit 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 email messages.
3 mailEncodingBinary Binary encoding is essentially the absence of any encoding performed on the message data, and there is no presumption that the data contains textual information. No character set localization or conversion is performed on binary encoded data. This encoding type is not recommended. Instead, binary data should be encoded using the standard base64 algorithm.
4 mailEncodingQuoted 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.
5 mailEncodingBase64 Base64 encoding is designed to represent binary data in a form that is not human readable but which can be safely exchanged with servers that only accept 7-bit data. Base64 encoding is typically used with file attachments.
6 mailEncodingUucode Uuencoding and uudecoding is a legacy encoding format that was used before the MIME standard was established. This encoding method has largely been replaced by base64 encoding, although it is still commonly used for binary newsgroup postings on USENET. Although this encoding format is supported, it is not officially part of the MIME standard and its use in email messages is discouraged.

Return Value

A value of zero is returned if the method succeeds. Otherwise, a non-zero error code is returned which indicates the cause of the failure.

Remarks

The CreatePart method creates a new message part. If the current message is a simple RFC822 message, then this method converts it to a MIME multipart message. The current message part will be set to the new part that was just created.

See Also

AttachFile Method, DeletePart Method