mail::mimestruct.3x man page

Cone©

mail::mimestruct — Message MIME structure

Synopsis

#include <libmail/structure.H>

mail::mimestruct myMimeStructure;

Usage

mail::mimestruct describes the contents of a MIME-formatted message. A multipart MIME message has a single mail::mimestruct object that represents the entire message, and series of mail::mimestruct objects, one object for each part of the multipart MIME section. The additional mail::mimestruct objects are maintained by their parent mail::mimestruct object, and are automatically destroyed when the parent object is destroyed.

A mail::mimestruct contains the following fields:

std::string mime_id

An opaque identifier of this MIME section. Applications should handle this field as an opaque text string, which is interpreted by LibMAIL . A same message, for example, may have different mime_id fields if it comes from an IMAP account, or a POP3 account.

The only exception to this rule is that the mail::mimestruct object that represents the entire message will have an empty string in mime_id.

std::string type

The major MIME type, in uppercase.

std::string subtype

The minor MIME subtype, in uppercase.

mail::mimestruct::parameterList type_parameters

Additional attributes parsed from the Content-Type: MIME header. See below for more information.

std::string content_id

The contents of the MIME Content-ID: header.

std::string content_description

The contents of the MIME Content-Description: header.

std::string content_transfer_encoding

The MIME encoding method.

std::string content_md5

The contents of the MIME Content-MD5: header.

std::string content_language

The contents of the MIME Content-Language: header.

std::string content_disposition

The MIME Content-Disposition: header, either "INLINE", or "ATTACHMENT" (or blank, if the header is not present).

size_t content_size

The approximate size of the MIME section, in bytes (for non-multipart MIME sections only).

size_t content_lines

Approximate number of lines in a TEXT MIME section.

mail::mimestruct::parameterList content_disposition_parameters

Additional attributes parsed from the Content-Disposition: MIME header. See below for more information.

mail::mimestruct methods

bool flag=messagerfc822();

Returns true if type is "MESSAGE" and subtype is "RFC822".

bool flag=messagerfc822()

Returns true if type is "MESSAGE" and subtype is "RFC822".

mail::envelope &myEnvelope=getEnvelope()

Returns a mail::envelope object, if messagerfc822 returns true.

size_t numChildren=getNumChildren()

Returns the number of MIME sections in a multipart MIME message.

mail::mimestruct *child=getChild(size_t childNum)

Returns a pointer to a mail::mimestruct object that represents a single part of a multipart MIME message. childNum must be between zero and one less than the number of parts returned by getNumChildren.

mail::mimestruct *parent=getParent()

Returns a pointer to a mail::mimestruct object that represents the parent of this MIME part, if this mail::mimestruct object represents a single part of a multipart MIME message. Returns NULL if this mail::mimestruct object represents the entire MIME message.

Note

mail::mimestruct objects that represent MESSAGE/RFC822 content should have getNumChildren return 1, and getChild with childNum set to 0 should return a pointer to a mail::mimestruct object that represents the MESSAGE/RFC822 message. However, getNumChildren may return 0 if the MIME message is corrupted.

Mail::Mimestruct::Parameterlist

A mail::mimestruct::parameterList object holds parsed MIME attributes in the Content-Type: and Content-Disposition: headers. A mail::mimestruct::parameterList object has the following methods:

bool flag=exists(std::string name);

This method returns true if the attribute name exists.

std::string str=get(std::string name, std::string charset);

Returns the value of attribute name (uppercase). If info is not NULL, the attribute's value is converted to the specified character set (if the attribute uses RFC 2231[1] to specify its character set and language).

void set(std::string name, std::string value, std::string charset, std::string language);

Set the attribute name to value. If charset and/or language are not empty strings, name's character set and language are indicated accordingly, as per RFC 2231[1].

mail::mimestruct::parameterList::iterator begin(), end(); mail::mimestruct::parameterList::const_iterator begin() const, end() const;

The begin and end functions return the equivalent iterators over the individual name/value MIME attributes. The iterators point to a std::pair<std::string, std::string>; first is the attribute name (uppercased), and second is its value. (The underlying structure being iterated is a std::map<std::string, std::string>.)

See Also

mail::envelope(3x), mail::account::readMessageAttributes(3x).

Author

Sam Varshavchik

Notes

1.

RFC 2231

Info

08/25/2013 Cone© Cone: COnsole Newsreader And E