public final class DEmailReceiver extends Object
folder(String folderName) method.
If you don't it, then the client will try to use the "INBOX" folder.
Checking and reading emails executes as pageable. By the default page has the size = 50 elements
and start index is 0. You can use a customize page request by using the methods supports pageable requests
(e.g. readEmail(PageRequest) or checkEmail(PageRequest)).
| Modifier and Type | Field and Description |
|---|---|
static PageRequest |
DEFAULT_PAGE_REQUEST
Default page request.
|
static String |
FOLDER_NAME_KEY_METADATA
The key to the folder name in the metadata of the response.
|
| Constructor and Description |
|---|
DEmailReceiver(ImapProperties properties)
The constructor of the class.
|
| Modifier and Type | Method and Description |
|---|---|
PageResponse<MessageView> |
checkEmail()
Checks email (first 50 messages).
|
PageResponse<MessageView> |
checkEmail(PageRequest pageRequest)
Checks email.
|
Map<Integer,Boolean> |
clearCurrentFolder()
Delete all messages in the current folder.
|
boolean |
deleteMessageById(Integer id)
Delete one message by the identifier.
|
Map<Integer,Boolean> |
deleteMessages(Collection<Integer> ids)
Delete several messages by its identifiers.
|
DEmailReceiver |
folder(String folderName)
Changes folder for reading messages.
|
String |
getCurrentFolder()
Returns a using folder in the mailbox.
|
static DEmailReceiver |
of(ImapProperties properties)
Creates instance of the
DEmailReceiver class. |
PageResponse<IncomingMessage> |
readEmail()
Reads email (first 50 messages).
|
PageResponse<IncomingMessage> |
readEmail(PageRequest pageRequest)
Reads email.
|
IncomingMessage |
readMessageById(Integer id)
Reads one email message by its identifier.
|
EmailParticipant |
receiver()
Returns email receiver object.
|
public static final PageRequest DEFAULT_PAGE_REQUEST
public static final String FOLDER_NAME_KEY_METADATA
public DEmailReceiver(ImapProperties properties)
properties - properties for connecting to an email server by IMAP protocolpublic static DEmailReceiver of(ImapProperties properties)
DEmailReceiver class.properties - properties for connecting to an email server by IMAP protocolDEmailReceiver classpublic DEmailReceiver folder(String folderName)
folderName - the name of folderDEmailReceiver classpublic EmailParticipant receiver()
EmailParticipant classpublic String getCurrentFolder()
public PageResponse<MessageView> checkEmail()
This method uses default page requests from the constant DEFAULT_PAGE_REQUEST.
PageResponse. Elements in the list of data have the type MessageView.public PageResponse<MessageView> checkEmail(PageRequest pageRequest)
This method supports page requests. You need to manage a page request yourself. Use the pageRequest parameter for it.
pageRequest - the configuration of a page requestPageResponse. Elements in the list of data have the type MessageView.public PageResponse<IncomingMessage> readEmail()
This method uses default page requests from the constant DEFAULT_PAGE_REQUEST.
PageResponse. Elements in the list of data have the type IncomingMessage.public PageResponse<IncomingMessage> readEmail(PageRequest pageRequest)
This method supports page requests. You need to manage a page request yourself. Use the pageRequest parameter for it.
pageRequest - the configuration of a page requestPageResponse. Elements in the list of data have the type IncomingMessage.public IncomingMessage readMessageById(Integer id)
id - identifier messageIncomingMessagepublic Map<Integer,Boolean> clearCurrentFolder()
folder(String folderName) to change folder. By default, it's "INBOX".public Map<Integer,Boolean> deleteMessages(Collection<Integer> ids)
ids - the list of message identifierspublic boolean deleteMessageById(Integer id)
id - the message identifierCopyright © 2023. All rights reserved.