Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space WBRIDGE and version 24.0

Otp

Methods for reading of email messages are provided by the ReadMessages class. You can:

  • read messages matching retrieval constraints (time window, subject line, unread, etc)
  • read all messages from the inbox folder
  • read specific messages from the inbox folder by message id
  • read messages from arbitrary folders
  • read specific messages from arbitrary folders by message id

Note that it is formally not guaranteed for message ids to be unique, not even within one folder. Therefore retrieval by id always returns an array of objects (which will most likely hold one element only).

Figure: The ReadMessages Class

Image Modified

All methods of this class return an array of objects of class Mail, which extends MailEnvelope and retrieves headers, content, and (multipart) attachments in addition.

Figure: The Mail Class

JavaMail_MailEnvelopeImage Modified

Reading All Messages From the Inbox

The following diagram demonstrates how to read all emails from the inbox:

JavaMail_ReadMessages_readMessagesImage Modified

Parameters of method readMessages in detail:

NameTypeDirectionDescription
connectionMailConnectionIn


Multiexcerpt
MultiExcerptNameconnection
Specifies connection details such as server name, protocol etc. (see Mail Connection).
deleteOnServerBooleanIn


Multiexcerpt
MultiExcerptNamedeleteonserver
When true, messages will be deleted on server after reading.
returnArray of MailReturn


Multiexcerpt
MultiExcerptNamearray_of_mail
An array containing emails from the inbox folder with the corresponding message id, or an empty array, if no emails were found.

Reading Specific Messages from the Inbox Folder by Id

Email messages can be accessed by their id through the readMessagesById method:

Image Modified

Parameters of method readMessagesById in detail:

NameTypeDirectionDescription
connectionMailConnectionIn
Multiexcerpt include
MultiExcerptNameconnection
nopaneltrue
PageWithExcerptReading Messages
idStringInId of the message.
returnArray of MailReturn
Multiexcerpt include
MultiExcerptNamearray_of_mail
nopaneltrue
PageWithExcerptReading Messages

Reading Messages From Arbitrary Folders

In addition to inbox folder, arbitrary folders on the mail server can be read with the readMessagesByFolder method:

Image Modified

Parameters of method readMessagesByFolder in detail:

NameTypeDirectionDescription
connectionMailConnectionIn
Multiexcerpt include
MultiExcerptNameconnection
nopaneltrue
PageWithExcerptReading Messages
folderStringInName of the folder to read.
deleteOnServerBooleanIn
Multiexcerpt include
MultiExcerptNamedeleteonserver
nopaneltrue
PageWithExcerptReading Messages
returnArray of MailReturn
Multiexcerpt include
MultiExcerptNamearray_of_mail
nopaneltrue
PageWithExcerptReading Messages

Reading Specific Messages From Arbitrary Folders by Id

In contrast to reading all messages from a folder, you can access a specific message from a folder by specifying its id and calling the readMessagesByFolderAndId method:

Image Modified

Parameters of method readMessagesByFolderAndId in detail:

NameTypeDirectionDescription
connectionMailConnectionIn
Multiexcerpt include
MultiExcerptNameconnection
nopaneltrue
PageWithExcerptReading Messages
idStringInId of the message.
folderStringInFolder, in which the message with the specified id is located.
returnArray of MailReturn
Multiexcerpt include
MultiExcerptNamearray_of_mail
nopaneltrue
PageWithExcerptReading Messages

Reading Specific Messages Using Retrieval Constraints

You can specify which messages to retrieve by providing a constraints object to the readMessagesWithConstraints method:

Image Modified

Parameters of method readMessagesWithConstraints in detail:

NameTypeDirectionDescription
connectionMailConnectionIn
Multiexcerpt include
MultiExcerptNameconnection
nopaneltrue
PageWithExcerptReading Messages
constraintsRetrievalConstraintsIn
Multiexcerpt
MultiExcerptNameRetrievalConstraints
Specifies constraints for mails to retrieve (see Mail Retrieval Constraints).
returnArray of MailReturn
Multiexcerpt include
MultiExcerptNamearray_of_mail
nopaneltrue
PageWithExcerptReading Messages
Panel
titleOn this Page:
Table of Contents