Home · All Classes · Grouped Classes · Annotated · Functions

QMailMessageBody Class Reference

The QMailMessageBody class contains the body element of a message or message part. More...

    #include <QMailMessageBody>

This class is under development and is subject to change.

Public Types

Public Functions

Static Public Members


Detailed Description

The QMailMessageBody class contains the body element of a message or message part.

The body of a message or message part is treated as an atomic unit by the Qtopia messaging library. It can only be inserted into a message part container or extracted from one. It can be inserted or extracted using either a QByteArray, a QDataStream or to/from a file. In the case of unicode text data, the insertion and extraction can operate on either a QString, a QTextStream or to/from a file.

The body data must be associated with a QMailMessageContentType describing that data. When extracting body data from a message or part to unicode text, the content type description must include a parameter named 'charset'; this parameter is used to locate a QTextCodec to be used to extract unicode data from the body data octet stream.

If the Content-Type of the data is a subtype of "text", then line-ending translation will be used to ensure that the text is transmitted with CR/LF line endings. The text data supplied to QMailMessageBody must conform to the RFC 2822 restrictions on maximum line lengths: "Each line of characters MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF." Textual message body data decoded from a QMailMessageBody object will have transmitted CR/LF line endings converted to \n on extraction.

The body data can also be encoded from 8-bit octets to 7-bit ASCII characters for safe transmission through obsolete email systems. When creating an instance of the QMailMessageBody class, the encoding to be used must be specified using the QMailMessageBody::TransferEncoding enum.

See also QMailMessagePart, QMailMessage, and QTextCodec.


Member Type Documentation

enum QMailMessageBody::EncodingFormat

This enum type is used to describe the format in which body data should be presented.

ConstantValueDescription
QMailMessageBody::Encoded1The body data should be presented in encoded form.
QMailMessageBody::Decoded2The body data should be presented in unencoded form.

enum QMailMessageBody::EncodingStatus

This enum type is used to describe the encoding status of body data.

ConstantValueDescription
QMailMessageBody::AlreadyEncoded1The body data is already encoded to the necessary encoding.
QMailMessageBody::RequiresEncoding2The body data is unencoded, and thus requires encoding for transmission.

enum QMailMessageBody::TransferEncoding

This enum type is used to describe a type of binary to text encoding. Encoding types used here are documented in RFC 2045 "Format of Internet Message Bodies"

ConstantValueDescription
QMailMessageBody::NoEncoding0The encoding is not specified.
QMailMessageBody::SevenBit1The data is not encoded, but contains only 7-bit ASCII data.
QMailMessageBody::EightBit2The data is not encoded, but contains data using only 8-bit characters which form a superset of ASCII.
QMailMessageBody::Base643A 65-character subset of US-ASCII is used, enabling 6 bits to be represented per printable character.
QMailMessageBody::QuotedPrintable4A method of encoding that tends to leave text similar to US-ASCII unmodified for readability.
QMailMessageBody::Binary5The data is not encoded to any limited subset of octet values.

See also QMailCodec.


Member Function Documentation

QMailMessageContentType QMailMessageBody::contentType () const

Returns the content type that the body was created with.

QByteArray QMailMessageBody::data ( EncodingFormat format ) const

Returns the data of the message body as a QByteArray. If format is QMailMessageBody::Encoded, then the data is written in the transfer encoding it was created with; otherwise, it is written in unencoded form.

See also QMailCodec.

QString QMailMessageBody::data () const

This is an overloaded member function, provided for convenience.

Returns the data of the message body as a QString, in unencoded form. Line-endings transmitted as CR/LF pairs are converted to \n on extraction.

The 'charset' parameter of the body's content type is used to locate the appropriate QTextCodec to convert the data from an octet stream to unicode, if necessary.

See also QMailCodec, QMailMessageContentType, and QTextCodec.

QMailMessageBody QMailMessageBody::fromData ( const QByteArray & input, const QMailMessageContentType & type, TransferEncoding encoding, EncodingStatus status )   [static]

Creates a message body from the data contained in input, having the content type type. If status is QMailMessageBody::RequiresEncoding, the data from the file will be encoded to encoding for transmission; otherwise it must already be in that encoding, which will be reported to recipients of the data.

If type is a subtype of "text", the data will be treated as text, and line-ending translation will be employed. Otherwise, the file will be treated as containing binary data.

If encoding is QMailMessageBody::QuotedPrintable, encoding will be performed assuming conformance to RFC 2045.

See also QMailCodec and QMailQuotedPrintableCodec.

QMailMessageBody QMailMessageBody::fromData ( const QString & input, const QMailMessageContentType & type, TransferEncoding encoding )   [static]

This is an overloaded member function, provided for convenience.

Creates a message body from the data contained in input, having the content type type. The data from input will be encoded to encoding for transmission, and line-ending translation will be employed. The unicode text data will be converted to an octet stream using a QTextCodec object identified by the 'charset' parameter of type.

If encoding is QMailMessageBody::QuotedPrintable, encoding will be performed assuming conformance to RFC 2045.

See also QMailCodec, QMailMessageContentType, and QTextCodec.

QMailMessageBody QMailMessageBody::fromFile ( const QString & filename, const QMailMessageContentType & type, TransferEncoding encoding, EncodingStatus status )   [static]

Creates a message body from the data contained in the file filename, having the content type type. If status is QMailMessageBody::RequiresEncoding, the data from the file will be encoded to encoding for transmission; otherwise it must already be in that encoding, which will be reported to recipients of the data.

If type is a subtype of "text", the data will be treated as text, and line-ending translation will be employed. Otherwise, the file will be treated as containing binary data. If the file contains unicode text data, it will be converted to an octet stream using a QTextCodec object identified by the 'charset' parameter of type.

If encoding is QMailMessageBody::QuotedPrintable, encoding will be performed assuming conformance to RFC 2045.

Note that the data is not actually read from the file until it is requested by another function.

See also QMailCodec, QMailQuotedPrintableCodec, QMailMessageContentType, and QTextCodec.

QMailMessageBody QMailMessageBody::fromStream ( QDataStream & in, const QMailMessageContentType & type, TransferEncoding encoding, EncodingStatus status )   [static]

Creates a message body from the data read from in, having the content type type. If status is QMailMessageBody::RequiresEncoding, the data from the file will be encoded to encoding for transmission; otherwise it must already be in that encoding, which will be reported to recipients of the data.

If type is a subtype of "text", the data will be treated as text, and line-ending translation will be employed. Otherwise, the file will be treated as containing binary data.

If encoding is QMailMessageBody::QuotedPrintable, encoding will be performed assuming conformance to RFC 2045.

See also QMailCodec and QMailQuotedPrintableCodec.

QMailMessageBody QMailMessageBody::fromStream ( QTextStream & in, const QMailMessageContentType & type, TransferEncoding encoding )   [static]

This is an overloaded member function, provided for convenience.

Creates a message body from the data read from in, having the content type type. The data read from in will be encoded to encoding for transmission, and line-ending translation will be employed. The unicode text data will be converted to an octet stream using a QTextCodec object identified by the 'charset' parameter of type.

If encoding is QMailMessageBody::QuotedPrintable, encoding will be performed assuming conformance to RFC 2045.

See also QMailCodec, QMailQuotedPrintableCodec, QMailMessageContentType, and QTextCodec.

bool QMailMessageBody::toFile ( const QString & filename, EncodingFormat format ) const

Writes the data of the message body to the file named filename. If format is QMailMessageBody::Encoded, then the data is written in the transfer encoding it was created with; otherwise, it is written in unencoded form.

If the body has a content type with a QMailMessageContentType::type() of "text", and the content type parameter 'charset' is not empty, then the unencoded data will be written as unicode text data, using the charset parameter to locate the appropriate QTextCodec.

Returns false if the operation causes an error; otherwise returns true.

See also QMailCodec, QMailMessageContentType, and QTextCodec.

bool QMailMessageBody::toStream ( QDataStream & out, EncodingFormat format ) const

Writes the data of the message body to the stream out. If format is QMailMessageBody::Encoded, then the data is written in the transfer encoding it was created with; otherwise, it is written in unencoded form.

Returns false if the operation causes an error; otherwise returns true.

See also QMailCodec.

bool QMailMessageBody::toStream ( QTextStream & out ) const

This is an overloaded member function, provided for convenience.

Writes the data of the message body to the stream out, in unencoded form. Line-endings transmitted as CR/LF pairs are converted to \n on extraction. Returns false if the operation causes an error; otherwise returns true.

The 'charset' parameter of the body's content type is used to locate the appropriate QTextCodec to convert the data from an octet stream to unicode, if necessary.

See also QMailCodec, QMailMessageContentType, and QTextCodec.

TransferEncoding QMailMessageBody::transferEncoding () const

Returns the transfer encoding type that the body was created with.


Copyright © 2008 Nokia Trademarks
Qtopia 4.3.3