mail::ACCOUNT::getMessageContent
Prev | mail::ACCOUNT Synchronous API reference | Next

## Name

mail::ACCOUNT::getMessageContent — Read message content

## Synopsis

#include <libmail/sync.H>
class myStoreCallback : public mail::ACCOUNT::Store {
public:
void search(size_t messageNumber, std::string messageContents);
};
myStoreCallback storeCallback;

mail::ACCOUNT *mail;

`bool ok=mail->getMessageContent(` | const std::vector<size_t> &msgList,
| bool peek,
| mail::readMode requestType,
| storeCallback`)`;

`bool ok=mail->getMessageContent(` | size_t messageNum,
| bool peek,
| const mail::mimestruct &messagePart,
| mail::readMode requestType,
| storeCallback`)`;

std::string errmsg=mail->getErrmsg();

## USAGE

`mail::ACCOUNT::getMessagesContent` reads messages in the currently open folder. There are two alternative versions of this method.

- The first version receives a list of message numbers. This version is capable of returning headers and/or content of multiple messages.

  `msgList` specifies a list of messages. Messages are numbered starting with message #0 and up to one less than mail::ACCOUNT::getFolderIndexSize(3x) (when `mail::account::getFolderIndexSize` returns 6, the messages are numbered 0 through 5). Only the messages that appear in `msgList` are processed by this request. When a message is removed from the folder, by mail::ACCOUNT::updateFolderIndexInfo(3x), the following messages are renumbered accordingly.

  ### Note

  Most mail servers allow multiple applications to open the same folder. Therefore, changes to the folder's contents can occur at any time. Before making this request, the application should use mail::ACCOUNT::checkNewMail(3x) to verify that no unexpected changes have been made to the folder's contents.

- The second version receives a single message number, and a mail::mimestruct object that refers to a single MIME attachment or a section of this message. The mail::mimestruct object was previously obtained from mail::ACCOUNT::getMessageStructure(3x), for this message. This method returns a recursive tree of mail::mimestruct objects which enumerates the individual MIME sections in the message. `messagePart` must be a reference to one of these objects (or to a copy of these objects).

Setting `peek` to true does not reset the `unread` message status flag for this message. Otherwise the `unread` message status flag will be reset.

`storeCallback`'s `store` method receives the requested content, which is determined by the remaining parameters.

`requestType` identifies the type of information to return from the selected MIME section, and must be set to one of the following values:

The callback method may not receive the entire requested content at once. Typically the method will be invoked multiple times; each time the method receives the next portion of the requested content. When requesting headers and/or content of multiple messages, they may be returned in any order, and the `messageNumber` parameter indicates which message's contents are being returned (note, however, that the entire contents of a given message are returned in their entirety, even when the callback method gets invoked multiple times for that message, before content from the next message are returned).

`mail::readHeadersFolded`

  Return only the headers of the MIME section. Folded headers are unfolded (the newline and the leading space on the next line are replaced with a single space character).

`mail::readHeaders`

  Return only the headers of the MIME section. The headers are returned as-is, without unfolding them.

`mail::readContents`

  Return the content of the MIME section.

  ### Note

  The MIME section is not decoded. Check the `Content-Transfer-Encoding` header to know what you're getting.

`mail::readBoth`

  Return the entire MIME section, as is: its headers, a blank line, then the contents.

## Return Codes

This method returns `true` if it succeeds, or `false` if it fails. If the method fails, use `mail::ACCOUNT::getErrmsg()` to read a brief description of the error.

## SEE ALSO

mail::ACCOUNT::getMessageContentDecoded(3x), mail::ACCOUNT::getMessageEnvelope(3x), mail::ACCOUNT::getMessageStructure(3x).

Prev | Up | Next
mail::ACCOUNT::getFolderKeywordInfo | Home | ToC | mail::ACCOUNT::getMessageContentDecoded