An IMAP4 FETCH response may optionally contain a BODY or BODYSTRUCTURE data item, which supplies information about the structure of a message stored on the server. BODYSTRUCTURE has the same fields as BODY, but adds additional fields. Since BODYSTRUCTURE provides more information than BODY, this library uses one class, BodyStructureData, for both IMAP4 structures. In the case of a BODY structure, some fields of the BodyStructureData object are empty.
The BODYSTRUCTURE structure is key to the effective use of IMAP4. One of the significant advantages of IMAP4 over POP3 is the ability to retrieve only the memo text part of a message, without retrieving any of the (possibly large) attachments. This ability requires the correct interpretation of the information provided in a BODYSTRUCTURE structure.
The contents of a BODYSTRUCTURE structure depend on the MIME media type of the message. In compound types, such as multipart or message/rfc822 types, there may be several BODYSTRUCTURE structures that are nested. The following table shows which fields are allowed in the BODYSTRUCTURE depending on the media type:
message/
text rfc822 multipart default
--------------------------------------------------------------------
media-type "TEXT" "MESSAGE" "MULTIPART" *
media-subtype * "RFC822" * *
content-type-params * * * *
content-id * * *
content-description * * *
content-transfer-encoding * * *
content-length * * *
content-md5 * * *
content-disposition * * * *
body-parts (1) *
envelope *
number-of-lines * *
--------------------------------------------------------------------
(1) A MESSAGE/RFC822 entity contains a single BODYSTRUCTURE structure,
which provides information about the encapsulated message.
Note that since certain header fields may be absent from a message, it is possible that some information will be unavailable. Unavailable information will be absent from the BODYSTRUCTURE data returned by the server.
To get the BODYSTRUCTURE information from the IMAP4 server, first send a FETCH command with a BODY or BODYSTRUCTURE data item. Use the function Imap4Client::Fetch to send this command. Then iterate over the returned responses to find the related FETCH response, represented by an instance of FetchResponse. Use the FetchResponse::BodyStructure member function to get the contained instance of BodyStructureData. Finally, extract the information from the BodyStructureData object.
Public Member Functions | |
| BodyStructureData () | |
| Default constructor. | |
| BodyStructureData (const BodyStructureData &other) | |
| Copy constructor. | |
| virtual | ~BodyStructureData () |
| Destructor. | |
| BodyStructureData & | operator= (const BodyStructureData &other) |
| Assignment operator. | |
| const char * | MediaType () const |
| Gets the media type. | |
| const char * | MediaSubtype () const |
| Gets the media subtype. | |
| unsigned | NumContentTypeParams () const |
| Gets the number of parameters in the Content-Type header. | |
| const char * | ContentTypeParamName (unsigned index) const |
| Gets the name of the parameter at the specified position in the Content-Type header field. | |
| const char * | ContentTypeParamValue (unsigned index) const |
| Gets the value of the parameter at the specified position in the Content-Type header field. | |
| const EnvelopeData * | Envelope () const |
| Gets the ENVELOPE structure. | |
| int | NumBodyParts () const |
| Gets the number of nested BODYSTRUCTURE items. | |
| const BodyStructureData * | BodyPart (unsigned index) const |
| Gets the BODYSTRUCTURE item at the specified position. | |
| const char * | ContentId () const |
| Gets the value of the Content-ID header field. | |
| const char * | ContentDescription () const |
| Gets the value of the Content-Description header field. | |
| const char * | ContentTransferEncoding () const |
| Gets the value of the Content-Transfer-Encoding header field. | |
| const char * | ContentDisposition () const |
| Gets the value of the Content-Disposition header field. | |
| unsigned | NumContentDispositionParams () const |
| Gets the number of parameters in the Content-Disposition header field. | |
| const char * | ContentDispositionParamName (unsigned index) const |
| Gets the name of the parameter at the specified position in the Content-Disposition header field. | |
| const char * | ContentDispositionParamValue (unsigned index) const |
| Gets the value of the parameter at the specified position in the Content-Disposition header field. | |
| const char * | ContentMd5 () const |
| Gets the value of the Content-MD5 header field. | |
| unsigned | Size () const |
| Gets the body size in bytes. | |
| unsigned | NumLines () const |
| Gets the number of lines in message or text body part. | |
| void | ImportData (const ListItem *root) |
| Called by the parser to set the data for this object. | |
|
|
Default constructor. |
|
|
Copy constructor.
|
|
|
Destructor. |
|
|
Gets the BODYSTRUCTURE item at the specified position. If the media type is multipart, the BODYSTRUCTURE structure should contain one or more nested BODYSTRUCTURE items. This function returns the nested BODYSTRUCTURE item at position index. The parameter index must satisfy index < NumBodyParts().
|
|
|
Gets the value of the Content-Description header field. If there is no Content-Description header field, the function returns an empty string.
|
|
|
Gets the value of the Content-Disposition header field (without the parameters). If there is no Content-Disposition header field, the function returns an empty string.
|
|
|
Gets the name of the parameter at the specified position in the Content-Disposition header field. The parameter index must satisfy index < NumContentDispositionParams().
|
|
|
Gets the value of the parameter at the specified position in the Content-Disposition header field. The parameter index must satisfy index < NumContentDispositionParams().
|
|
|
Gets the value of the Content-ID header field. If there is no Content-ID header field, the function returns an empty string.
|
|
|
Gets the value of the Content-MD5 header field. If there is no Content-MD5 header field, the function returns an empty string.
|
|
|
Gets the value of the Content-Transfer-Encoding header field. If there is no Content-Transfer-Encoding header field, the function returns an empty string.
|
|
|
Gets the name of the parameter at the specified position in the Content-Type header field. The parameter index must satisfy index < NumContentTypeParams().
|
|
|
Gets the value of the parameter at the specified position in the Content-Type header field. The parameter index must satisfy index < NumContentTypeParams().
|
|
|
Gets the ENVELOPE structure. This item is present only if the media type is "MESSAGE/RFC822", and it describes the header fields of the encapsulated message.
|
|
|
Called by the parser to set the data for this object. Only the parser should call this function.
|
|
|
Gets the media subtype. Content in the MIME standard is labeled with a media type, such as "text/plain" or "image/jpeg". The media type consists of a primary media type, such as "text" or "image", and a subtype, such as "plain" or "jpeg". This function returns the media subtype of the referenced content.
|
|
|
Gets the primary media type. Content in the MIME standard is labeled with a media type, such as "text/plain" or "image/jpeg". The media type consists of a primary media type, such as "text" or "image", and a subtype, such as "plain" or "jpeg". This function returns the primary media type of the referenced content.
|
|
|
Gets the number of nested BODYSTRUCTURE items. The value is nonzero only if the media type is MULTIPART or MESSAGE/RFC822. Use the BodyPart() member function to get the BODYSTRUCTURE structure for a specified body part.
|
|
|
Gets the number of parameters in the Content-Disposition header field. Use the member function ContentDispositionParamName to get the name of a parameter, and use the member function ContentDispositionParamValue to get the value of a parameter.
|
|
|
Gets the number of parameters in the Content-Type header. Use the member function ContentTypeParamName to get the name of a parameter, and use the member function ContentTypeParamValue to get the value of a parameter.
|
|
|
Gets the number of lines in message or text body part.
|
|
|
Assignment operator.
|
|
|
Gets the size of the body in bytes.
|
Copyright © 2001-2005 Hunny Software, Inc. All rights reserved.