Class ReadMessageEnvelopes provides methods for reading message envelopes. This may be beneficial in a scenario where you first have to scan the messages on the server, before to decide which one you really want to read. In contrast to class  ReadMessages, methods of ReadMessageEnvelopes do not read and transfer the whole message content (such as content and attachments, which could be rather large), but only the header fields (sender, recipient etc.). Therefore, these methods will perform better and use less memory in comparison to methods of the ReadMessages class.

Figure: The ReadMessageEnvelopes Class

JavaMail_ReadMessageEnvelopes

All methods of ReadMessageEnvelopes return an Array of MailEnvelope objects:

Figure: The MailEnvelope Class

 JavaMail_MailEnvelope

Reading Specific Message Envelopes Using Retrieval Constraints

You can specify which message envelopes to retrieve by providing a constraints object to the readMessageEnvelopesWithConstraints method:

Parameters of method readMessageEnvelopesWithConstraints in detail:

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

Reading all Message Envelopes from the Inbox Folder

Method readMessageEnvelopes reads all message envelopes from the inbox folder:

JavaMail_ReadMessageEnvelopes_readMessageEnvelopes

Parameters of method readMessageEnvelopes in detail:

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

Reading Message Envelopes from an Arbitrary Folder

You can read email envelopes from an arbitrary folder on the mail server by using the readMessageEnvelopesByFolder method:

JavaMail_ReadMessageEnvelopes_readEnvelopesByFolder

Parameters of method readMessageEnvelopesByFolder in detail:

Name
Type
Direction
Description
connectionMailConnectionInSpecifies connection details such as server name, protocol etc. (see Mail Connection).
folderStringInSpecifies the folder on the mail server.
returnArray of MailEnvelopeReturnAn array containing mail envelopes from the specified folder, or an empty array, if no emails were found.
On this Page:
  • No labels