public class IMAPDClient extends Object implements ReceiverDClient
ReceiverDClient.
It provides opportunities for reading messages from email using the IMAP protocol. An IMAP connection will be
established by creating the class at once. Then, you need to set up a store - email account. An IMAP connection may
work with only one account at one time.
You should use the instance of the ImapProperties class, for configure this class.
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_INBOX_FOLDER_NAME
The default name of the inbox mail folder.
|
static String |
DEFAULT_OUTBOX_FOLDER_NAME
The default name of the outbox mail folder.
|
| Constructor and Description |
|---|
IMAPDClient(ImapProperties imapProperties)
Constructor of the class.
|
| Modifier and Type | Method and Description |
|---|---|
List<MessageView> |
checkEmailMessages(String folderName,
PageRequest pageRequest)
Returns short information about messages.
|
void |
closeFolder(jakarta.mail.Folder folder)
Closes the opened folder.
|
jakarta.mail.Session |
connect()
Connects to the email server using the IMAP protocol.
|
Map<Integer,Boolean> |
deleteAllMessages(String folderName)
Deletes all messages in a folder.
|
boolean |
deleteMessage(String folderName,
int id)
Deletes a message in a folder by its ID.
|
Map<Integer,Boolean> |
deleteMessages(String folderName,
Collection<Integer> ids)
Deletes several messages in a folder by their IDs.
|
EmailParticipant |
getPrincipal()
Returns name and email address used for connection.
|
String |
getProtocolName()
Returns a using protocol name.
|
Integer |
getTotalCount(String folderName)
Returns the total count of email messages in the folder.
|
jakarta.mail.Folder |
openFolderForRead(String folderName)
Opens the folder for only read.
|
jakarta.mail.Folder |
openFolderForWrite(String folderName)
Opens the folder for read and write.
|
IncomingMessage |
readMessageById(String folderName,
int id)
Reads message by its ID (number message).
|
List<IncomingMessage> |
readMessages(String folderName,
PageRequest pageRequest)
Return full information about messages.
|
public static final String DEFAULT_INBOX_FOLDER_NAME
public static final String DEFAULT_OUTBOX_FOLDER_NAME
public IMAPDClient(ImapProperties imapProperties)
An IMAP connection and store will be created with the class at once.
imapProperties - properties for creating an IMAP connectionpublic jakarta.mail.Session connect()
throws SessionException
connect in interface DClientSession objectSessionException - The connection to the server has failed. The properties are broken.public final String getProtocolName()
getProtocolName in interface DClientpublic final EmailParticipant getPrincipal()
getPrincipal in interface DClientpublic Integer getTotalCount(String folderName)
getTotalCount in interface ReceiverDClientfolderName - the folder name (For example: INBOX, OUTBOX, etc.)public List<MessageView> checkEmailMessages(String folderName, PageRequest pageRequest)
checkEmailMessages in interface ReceiverDClientfolderName - the folder name in you accountpageRequest - selection size informationMessageViewpublic List<IncomingMessage> readMessages(String folderName, PageRequest pageRequest)
readMessages in interface ReceiverDClientfolderName - the folder name in you accountpageRequest - selection size informationIncomingMessagepublic IncomingMessage readMessageById(String folderName, int id)
readMessageById in interface ReceiverDClientfolderName - the folder name in you accountid - unique identifier of a message within the folderIncomingMessagepublic jakarta.mail.Folder openFolderForRead(String folderName)
openFolderForRead in interface ReceiverDClientfolderName - the folder name in you accountFolderpublic jakarta.mail.Folder openFolderForWrite(String folderName)
openFolderForWrite in interface ReceiverDClientfolderName - the folder name in you accountFolderpublic void closeFolder(jakarta.mail.Folder folder)
closeFolder in interface ReceiverDClientfolder - an object of the class Folderpublic boolean deleteMessage(String folderName, int id)
deleteMessage in interface ReceiverDClientfolderName - the folder name in you accountid - unique identifier of a message within the folderpublic Map<Integer,Boolean> deleteMessages(String folderName, Collection<Integer> ids)
deleteMessages in interface ReceiverDClientfolderName - the folder name in you accountids - unique identifiers of messages within the folderpublic Map<Integer,Boolean> deleteAllMessages(String folderName)
deleteAllMessages in interface ReceiverDClientfolderName - the folder name in you accountCopyright © 2023. All rights reserved.