Reading Email Envelopes
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
All methods of ReadMessageEnvelopes return an Array of MailEnvelope objects:
Figure: The MailEnvelope Class
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:
Name | Type | Direction | Remarks |
---|---|---|---|
connection | MailConnection | In | Specifies connection details such as server name, protocol etc. (see Mail Connection). |
constraints | RetrievalConstraints | In | Specifies constraints for mails to retrieve (see Mail Retrieval Constraints). |
return | Array of MailEnvelope | Return | An 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:
Parameters of method readMessageEnvelopes in detail:
Name | Type | Direction | Description |
---|---|---|---|
connection | MailConnection | In | Specifies connection details such as server name, protocol etc. (see Mail Connection). |
return | Array of MailEnvelope | Return | An 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:
Parameters of method readMessageEnvelopesByFolder in detail:
Name | Type | Direction | Description |
---|---|---|---|
connection | MailConnection | In | Specifies connection details such as server name, protocol etc. (see Mail Connection). |
folder | String | In | Specifies the folder on the mail server. |
return | Array of MailEnvelope | Return | An array containing mail envelopes from the specified folder, or an empty array, if no emails were found. |