Class ReadMessages provides methods for reading messages from the inbox or from arbitrary folders on the server. In addition, in case of multipart/multi-content messages, the messages are parsed and the content and/or attachments are returned in appropriate array attributes of the Mail class. This behavior is useful in most cases, but not always. For scenarios that require access to raw (unparsed) content of the message, you should use class ReadRawTextMessages.

Figure: The ReadRawTextMessages Class

JavaMail_ReadRawTextMessages

All methods of ReadRawTextmessages return an Array of RawTextMessage objects:

JavaMail_RawTextMessage

The RawTextMail class contains all attributes from Mail and MailEnvelope classes and adds an attribute for the raw message text as an instance of Blob.

Reading Specific Raw Text Messages Using Retrieval Constraints

You can specify which raw text messages to retrieve by providing a constraints object to the readRawTextMessagesWithConstraints method:

Parameters of method readMessagesWithConstraints in detail:

NameTypeDirectionDescription
connectionMailConnectionInSpecifies connection details such as server name, protocol etc. (see Mail Connection).
constraintsRetrievalConstraintsInSpecifies constraints for mails to retrieve (see Mail Retrieval Constraints).
returnArray of RawTextMailReturnAn array containing emails matching the constraints, or an empty array, if no emails were found.

Reading All Raw Text Messages from the Inbox

To read all raw text messages from the inbox, use the readRawTextMessages method:

JavaMail_ReadRawTextMessages_readRawTextMessages

Parameters of method readRawTextMessages in detail:

Name
Type
Direction
Description
connectionMailConnectionInSpecifies connection details such as server name, protocol etc. (see Mail Connection).
deleteOnServerBooleanInWhen true, messages will be deleted on server after reading.
returnArray of RawTextMailReturnAn array containing emails from the inbox folder with the corresponding message id, or an empty array, if no emails were found.

Reading Raw Text Messages from Inbox Folder by Id

The method readRawTextMessagesById provides the means to read a message from the inbox folder by specifying the message id:

JavaMail_ReadRawTextMessages_readRawTextMessagesById

Name
Type
Direction
Description
connectionMailConnectionInSpecifies connection details such as server name, protocol etc. (see Mail Connection).
idStringInId of the message
returnArray of RawTextMailReturnAn array containing emails from the inbox folder with the corresponding message id, or an empty array, if no emails were found.

Reading Raw Text Messages from Arbitrary Folders

You can use the readRawTextMessagesByFolder method to read raw text messages from arbitrary folders on the mail server:

JavaMail_ReadRawTextMessages_readRawTextMessagesByFolder

Name
Type
Direction
Description
connectionMailConnectionInSpecifies connection details such as server name, protocol etc. (see Mail Connection).
deleteOnServerBooleanInWhen true, messages will be deleted on server after reading.
folderStringInName of the folder to read.
returnArray of RawTextMailReturnAn array containing emails from the inbox folder with the corresponding message id, or an empty array, if no emails were found.
On this Page:
  • No labels