Package com.netlang.mail
Class MailFolder
java.lang.Object
com.netlang.mail.MailFolder
- Direct Known Subclasses:
Mailbox
This class represent a folder in a POP3 server.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close mailboxcreateFolder(String name) Create a folder for messagescreateFolderContainer(String name) Create a folder containing other foldersvoidvoiddeleteMessages(String from, String subject, String body) voiddeleteMessages(Date after, Date before) voidSearch mailbox folder and position to first elementintGet the deleted message countGet the unread messagesjavax.mail.FolderGet the internal JavaMail folderGet a mail folderString[]Returns a list with mailfoldersReturns a list with mailfoldersgetFolders(String pattern) List the folders under this folderThe full name of this foldergetLastMessages(int maxcount) Returns the latest messages in the folder.getMessage(int index) Get the message at the specified indexintGet the message countGet all messages in this foldergetMessages(int start, int end) Get the messages in this folder for message numbers ranging from start through end, both start and end inclusive.getName()Return the name of the folderintGet number of new messagesintGet the unread message countReturns all unread messages in this folder.booleanhasMore()Return true if there are more mail to read The first(..) method must be called before this value is validvoidvoidmoveMessage(MailMessage msg) voidmoveMessages(MailFolder to, String from, String subject, String body) voidmoveMessages(MailFolder to, Date after, Date before) voidnext()Get next mailvoidOpen the folder for updatesvoidRemove deleted messagessearchMessages(String text) Search for the messagessearchMessages(String from, String subject, String body, Date after, Date before, int answerOption, String to, String cc, String bcc) Search for the messages.searchMessages(Date after, Date before) Search for the messages.searchMessages(javax.mail.search.SearchTerm term) Search for the messagesjavax.mail.Message[]searchMessagesInternal(javax.mail.search.SearchTerm term) Search for the messages
-
Method Details
-
permanentlyRemoveDeleted
public void permanentlyRemoveDeleted() throws javax.mail.MessagingExceptionRemove deleted messages- Throws:
javax.mail.MessagingException
-
openForUpdate
public void openForUpdate() throws javax.mail.MessagingExceptionOpen the folder for updates- Throws:
javax.mail.MessagingException
-
close
public void close()Close mailbox -
getName
Return the name of the folder- Returns:
- the name of this folder.
-
getFullName
The full name of this folder- Returns:
- the full name
-
getFolder
public javax.mail.Folder getFolder()Get the internal JavaMail folder- Returns:
- the folder
-
getMessageCount
Get the message count- Returns:
- the number of messages in the folder
- Throws:
Exception
-
getUnreadMessageCount
Get the unread message count- Returns:
- the number of unread messages in the folder
- Throws:
Exception
-
getDeletedMessageCount
Get the deleted message count- Returns:
- the number of deleted messages in the folder
- Throws:
Exception
-
getNewMessageCount
Get number of new messages- Returns:
- Throws:
Exception
-
getMessage
Get the message at the specified index- Parameters:
index- the one based index of the message in the folder- Returns:
- the message
- Throws:
Exception
-
getMessages
Get all messages in this folder- Returns:
- array with messages.
- Throws:
Exception
-
getMessages
Get the messages in this folder for message numbers ranging from start through end, both start and end inclusive.- Returns:
- array with messages.
- Throws:
Exception
-
getLastMessages
Returns the latest messages in the folder.- Throws:
Exception
-
getUnreadMessages
Returns all unread messages in this folder.- Returns:
- all unread mails.
- Throws:
Exception
-
getDeletedMessages
Get the unread messages- Throws:
Exception
-
searchMessages
Search for the messages. Wildcard * are supported. A parameter value of null is the same as * which will match all messages- Parameters:
from- the from field search termsubject- search for something in the subjectmessage- the search term for the message bodyattachement- search for an attachment name- Returns:
- the search result
- Throws:
Exception
-
searchMessages
Search for the messages- Parameters:
text- any text that will be searched for in subject and body- Returns:
- search result
- Throws:
Exception
-
searchMessages
public List<MailMessage> searchMessages(String from, String subject, String body, Date after, Date before, int answerOption, String to, String cc, String bcc) throws Exception Search for the messages. Wildcard * are supported. A parameter value of null is the same as * which will match all messages- Parameters:
from- the from field search termsubject- search for something in the subjectmessage- the search term for the message bodyattachement- search for an attachment name- Returns:
- the search result
- Throws:
Exception
-
searchMessagesInternal
public javax.mail.Message[] searchMessagesInternal(javax.mail.search.SearchTerm term) throws Exception Search for the messages- Parameters:
term- the term to search for Example SearchTerm term = new AndTerm(new SubjectTerm("hello"), new BodyTerm("hello"));- Returns:
- Throws:
Exception
-
searchMessages
Search for the messages- Parameters:
term- the term to search for Example SearchTerm term = new AndTerm(new SubjectTerm("hello"), new BodyTerm("hello"));- Returns:
- Throws:
Exception
-
getFolder
Get a mail folder- Parameters:
name- the name of the folderwriteAccess- set this to true if write access is required- Returns:
- the mailfolder
- Throws:
Exception
-
getFolder
- Throws:
Exception
-
getFolderNames
Returns a list with mailfolders- Returns:
- Throws:
Exception
-
getFolders
Returns a list with mailfolders- Returns:
- Throws:
Exception
-
getFolders
List the folders under this folder- Parameters:
pattern- return only folders matching the patternAs an example, given the folder hierarchy: Personal/ Finance/ Stocks Bonus StockOptions Jokes getFolders("*") on "Personal" will return the whole hierarchy. getFolders("%") on "Personal" will return "Finance" and "Jokes". getFolders("Jokes") on "Personal" will return "Jokes". getFolders("Stock*") on "Finance" will return "Stocks" and "StockOptions".- Returns:
- Throws:
Exception
-
createFolderContainer
Create a folder containing other folders- Parameters:
name- the name of the folder to create- Returns:
- Throws:
Exception
-
createFolder
Create a folder for messages- Parameters:
name- the name of the folder to create- Returns:
- Throws:
Exception
-
hasMore
public boolean hasMore()Return true if there are more mail to read The first(..) method must be called before this value is valid- Returns:
-
first
public MailMessage first(String from, String subject, String message, boolean removeAfterRead) throws Exception Search mailbox folder and position to first element- Parameters:
from-subject-message-attachement-removeAfterRead-- Returns:
- Throws:
Exception
-
next
Get next mail- Returns:
- Throws:
Exception
-
moveMessage
- Throws:
Exception
-
moveUnreadMessages
- Throws:
com.net4z.APIException
-
moveAllMessages
- Throws:
com.net4z.APIException
-
moveMessages
- Throws:
com.net4z.APIException
-
moveMessages
public void moveMessages(MailFolder to, String from, String subject, String body) throws com.net4z.APIException - Throws:
com.net4z.APIException
-
deleteUnreadMessages
public void deleteUnreadMessages() throws com.net4z.APIException- Throws:
com.net4z.APIException
-
deleteAllMessages
public void deleteAllMessages() throws com.net4z.APIException- Throws:
com.net4z.APIException
-
deleteMessages
- Throws:
com.net4z.APIException
-
deleteMessages
- Throws:
com.net4z.APIException
-