Class DefaultMailReader
java.lang.Object
de.muehlencord.shared.network.mail.DefaultMailReader
- All Implemented Interfaces:
MailReader
- Direct Known Subclasses:
ImapMailReader
MailReader to connect and work with IMAP mailboxes. Also works with exchange servers.
- Author:
- Joern Muehlencord (joern@muehlencord.de)
-
Constructor Summary
ConstructorsConstructorDescriptioncreates a new instance of the DefaultMailReader and updates needed values and settings -
Method Summary
Modifier and TypeMethodDescriptionabstract voidconnect()connects to the mailboxvoidcopyMessage(MailMessage mm, String sourceFolder, String destFolder) copies the given message from the source folder to the destination foldervoiddisconnects from mailboxprotected MailReaderConfigurationreturns the configuration objectreturns the default folderprotected javax.mail.Sessionreturns the session object to usereturns the folder, if folder path is a valid path to an existing folderintgetMessageCount(String sourceFolder) returns the message count for the given foldergetMessages(String sourceFolder) retrieves the list of messages stored in the given foldergetMessages(String sourceFolder, int start, int end) retrieves the list of messages stored in the given folderprotected javax.mail.StoregetStore()getSubFolder(String sourceFolder) returns the list of subfolders of the specified source foldergetSubFolder(javax.mail.Folder sourceFolder) returns the list of subfolders of the specified source foldervoidmoveMessage(MailMessage mm, String sourceFolder, String destFolder) moves the given message from the source folder to the destination foldervoidsetSeenFlag(String folderName, MailMessage mm, boolean flagValue) marks the messages as seenprotected voidsetStore(javax.mail.Store store)
-
Constructor Details
-
Method Details
-
connect
connects to the mailbox- Specified by:
connectin interfaceMailReader- Throws:
MailReaderConnectionException- if the connection cannot be established
-
disconnect
-
getDefaultFolder
returns the default folder- Specified by:
getDefaultFolderin interfaceMailReader- Returns:
- the default folder
- Throws:
MailReaderException- if the default folder cannot be found
-
getSubFolder
returns the list of subfolders of the specified source folder- Parameters:
sourceFolder- the folder to return the folder list for- Returns:
- the list of subfolders of the specified source folder
- Throws:
MailReaderException- if the folder list cannot be retrieved
-
getDefaultSession
protected javax.mail.Session getDefaultSession()returns the session object to use- Returns:
- the session object to use
-
getStore
protected javax.mail.Store getStore()- Returns:
- the store
-
setStore
protected void setStore(javax.mail.Store store) - Parameters:
store- the store to set
-
getConfiguration
returns the configuration object- Returns:
- returns the configuration
-
getFolder
returns the folder, if folder path is a valid path to an existing folder- Specified by:
getFolderin interfaceMailReader- Parameters:
folderPath- the folder to return- Returns:
- the folder, if folder path is a valid path to an existing folder
- Throws:
MailReaderException- if the folder cannot be found
-
getSubFolder
returns the list of subfolders of the specified source folder- Specified by:
getSubFolderin interfaceMailReader- Parameters:
sourceFolder- the folder to return the folder list for- Returns:
- the list of subfolders of the specified source folder
- Throws:
MailReaderException- if the folder list cannot be retrieved
-
getMessageCount
returns the message count for the given folder- Specified by:
getMessageCountin interfaceMailReader- Parameters:
sourceFolder- the folder to return the message count for- Returns:
- the message count for the given folder
- Throws:
MailReaderException- if the amount of messages cannot be determined
-
getMessages
retrieves the list of messages stored in the given folder- Specified by:
getMessagesin interfaceMailReader- Parameters:
sourceFolder- the folder to search return the emails for- Returns:
- list of messages stored in the given folder
- Throws:
MailReaderException- if the message list cannot be retrieved
-
getMessages
public List<MailMessage> getMessages(String sourceFolder, int start, int end) throws MailReaderException retrieves the list of messages stored in the given folder- Specified by:
getMessagesin interfaceMailReader- Parameters:
sourceFolder- the folder to search return the emails forstart- the number of the first messageend- the number of the last message- Returns:
- list of messages stored in the given folder
- Throws:
MailReaderException- if the message list cannot be retrieved
-