public class ReceiveMailSession
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
jodd.mail.MailSession.Defaults |
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
DEFAULT_FOLDER
Default folder.
|
protected javax.mail.Service |
service |
Constructor and Description |
---|
ReceiveMailSession(javax.mail.Session session,
javax.mail.Store store,
java.io.File attachmentStorage)
Creates new mail session.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes session.
|
protected void |
closeFolderIfOpened(javax.mail.Folder folder)
Closes folder if opened and expunge deleted messages.
|
java.lang.String[] |
getAllFolders()
Returns array of all
Folder s as String s. |
int |
getDeletedMessageCount()
Returns the number of deleted messages.
|
javax.mail.Folder |
getFolder(java.lang.String folder)
Just returns a folder, w/o opening.
|
int |
getMessageCount()
Returns number of messages.
|
int |
getNewMessageCount()
Returns the number of new messages.
|
javax.mail.Store |
getService()
Returns the
Service . |
javax.mail.Session |
getSession()
Returns the
Session . |
int |
getUnreadMessageCount()
Returns the number of unread messages.
|
boolean |
isConnected()
Returns
true if mail session is still connected. |
void |
open()
Opens session.
|
ReceiverBuilder |
receive()
Defines the process of received email in an fluent way.
|
ReceivedEmail[] |
receiveEmail()
Receives all emails.
|
ReceivedEmail[] |
receiveEmail(EmailFilter filter)
Receives all emails that matches given
EmailFilter . |
ReceivedEmail[] |
receiveEmailAndDelete()
Receives all emails and mark all messages as 'seen' and 'deleted'.
|
ReceivedEmail[] |
receiveEmailAndDelete(EmailFilter filter)
Receives all emails that matches given
EmailFilter and
mark all messages as 'seen' and 'deleted'. |
ReceivedEmail[] |
receiveEmailAndMarkSeen()
Receives all emails and mark all messages as 'seen' (ie 'read').
|
ReceivedEmail[] |
receiveEmailAndMarkSeen(EmailFilter filter)
Receives all emails that matches given
EmailFilter
and mark them as 'seen' (ie 'read'). |
ReceivedEmail[] |
receiveEnvelopes() |
ReceivedEmail[] |
receiveEnvelopes(EmailFilter filter) |
protected static void |
setupSystemMailProperties()
Setups the system email properties.
|
void |
updateEmailFlags(ReceivedEmail receivedEmail)
Updates the email flags on the server.
|
void |
useDefaultFolder()
Opens default folder: DEFAULT_FOLDER.
|
void |
useFolder(java.lang.String folderName)
Opens new folder and closes previously opened folder.
|
protected static final java.lang.String DEFAULT_FOLDER
protected final javax.mail.Service service
public ReceiveMailSession(javax.mail.Session session, javax.mail.Store store, java.io.File attachmentStorage)
session
- Session
.store
- Store
.public javax.mail.Store getService()
Service
.Service
.public java.lang.String[] getAllFolders()
Folder
s as String
s.public void useFolder(java.lang.String folderName)
folderName
- Folder to openpublic javax.mail.Folder getFolder(java.lang.String folder)
public void useDefaultFolder()
public int getMessageCount()
public int getNewMessageCount()
public int getUnreadMessageCount()
public int getDeletedMessageCount()
public ReceiverBuilder receive()
public ReceivedEmail[] receiveEmail()
ReceivedEmail
s.public ReceivedEmail[] receiveEmail(EmailFilter filter)
EmailFilter
.
Messages are not modified. However, servers may set SEEN flag anyway,
so we force messages to remain unseen.filter
- EmailFilter
ReceivedEmail
s.public ReceivedEmail[] receiveEmailAndMarkSeen()
ReceivedEmail
s.receiveEmailAndMarkSeen(EmailFilter)
public ReceivedEmail[] receiveEmailAndMarkSeen(EmailFilter filter)
EmailFilter
and mark them as 'seen' (ie 'read').filter
- EmailFilter
ReceivedEmail
s.public ReceivedEmail[] receiveEmailAndDelete()
ReceivedEmail
s.public ReceivedEmail[] receiveEmailAndDelete(EmailFilter filter)
EmailFilter
and
mark all messages as 'seen' and 'deleted'.filter
- EmailFilter
ReceivedEmail
s.public ReceivedEmail[] receiveEnvelopes()
public ReceivedEmail[] receiveEnvelopes(EmailFilter filter)
public void updateEmailFlags(ReceivedEmail receivedEmail)
protected void closeFolderIfOpened(javax.mail.Folder folder)
public void close()
close
in interface java.lang.AutoCloseable
protected static void setupSystemMailProperties()
public void open()
public boolean isConnected()
true
if mail session is still connected.true
if mail session is still connected.public javax.mail.Session getSession()
Session
.Session
.Copyright © 2003-present Jodd Team