本文整理汇总了Java中javax.mail.Folder.HOLDS_MESSAGES属性的典型用法代码示例。如果您正苦于以下问题:Java Folder.HOLDS_MESSAGES属性的具体用法?Java Folder.HOLDS_MESSAGES怎么用?Java Folder.HOLDS_MESSAGES使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.mail.Folder
的用法示例。
在下文中一共展示了Folder.HOLDS_MESSAGES属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: receiveByFolder
public void receiveByFolder(Folder folder, JavamailConfig javamailConfig)
throws MessagingException, IOException {
logger.info("receive : {}", folder);
if ((Folder.HOLDS_MESSAGES & folder.getType()) != 0) {
this.receiveMessageByFolder(folder, javamailConfig);
}
if ((Folder.HOLDS_FOLDERS & folder.getType()) != 0) {
for (Folder childFolder : folder.list()) {
this.receiveByFolder(childFolder, javamailConfig);
}
}
if (folder.isOpen()) {
// 关闭资源
folder.close(false);
}
}
示例2: checkEmails
void checkEmails(int maxnum, boolean notify) {
try {
if (!mailFolder.exists()) return;
if ((mailFolder.getType() & Folder.HOLDS_MESSAGES) == 0) return;
mailFolder.open(Folder.READ_ONLY);
int totalcount = mailFolder.getMessageCount();
// System.err.println(mailFolder + " " + count);
int count = Math.min(maxnum, totalcount);
// get "count" last messages
int end = totalcount;
int start = end - count + 1;
Message[] messages = mailFolder.getMessages(start, end);
addMessages(messages, notify);
mailFolder.close(false);
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: clear
private static void clear(Folder folder) throws MessagingException {
if(folder.exists() && (folder.getType() & Folder.HOLDS_MESSAGES) == Folder.HOLDS_MESSAGES) {
int totMessages = folder.getMessageCount();
System.out.println(totMessages + " messages from folder: " + folder.getFullName());
folder.open(Folder.READ_WRITE);
Message[] messages = folder.getMessages();
for (int i = 0; i < messages.length; i++) {
System.out.println("Deleting message: " + (i+1) + " of " + totMessages);
messages[i].setFlag(Flags.Flag.DELETED, true);
}
folder.close(true);
}
Folder[] childs = folder.list();
for (int i = 0; i < childs.length; i++) {
clear(childs[i]);
}
}
示例4: FolderData
/**
* @param data the user who owns this folder
* @param folder the folder being reflected
*/
public FolderData(AccountData data, Folder folder) throws MessagingException
{
_folder = folder;
_accountData = data;
_holdsMessages = (_folder.getType() & Folder.HOLDS_MESSAGES) > 0;
}
示例5: listFolder
static void listFolder(Folder folder, String tab, boolean recurse)
throws Exception {
folder.open(Folder.READ_WRITE);
System.out.println(tab + "Name: " + folder.getName() + '(' +
folder.getFullName() + ')');
if (!folder.isSubscribed())
System.out.println(tab + "Not Subscribed");
if ((folder.getType() & Folder.HOLDS_MESSAGES) != 0) {
if (folder.hasNewMessages())
System.out.println(tab + "Has New Messages");
else
System.out.println(tab + "No New Messages");
Message[] msgs = folder.getMessages();
for (Message m : msgs) {
Address from = m.getFrom()[0];
String fromAddress;
if (from instanceof InternetAddress)
fromAddress = ((InternetAddress)from).getAddress();
else
fromAddress = from.toString();
StringBuffer sb = new StringBuffer();
fromFmt.format(fromAddress, sb, null);
sb. append(" ");
subjFmt.format(m.getSubject(), sb, null);
System.out.println(sb.toString());
}
}
if ((folder.getType() & Folder.HOLDS_FOLDERS) != 0) {
System.out.println(tab + "Is Directory");
}
if (recurse) {
Folder[] fs = folder.list();
for (Folder f : fs) {
listFolder(f, tab + "", recurse);
}
}
}
示例6: FolderIterator
public FolderIterator(JavaxMailFolder folder) {
this.folder = folder;
logger.fine(() -> "Opening folder:" + folder.getName());
if (!folder.isOpen()) {
folder.open(Folder.READ_ONLY);
}
this.messageIterator = (folder.getType() & Folder.HOLDS_MESSAGES) > 0
? new MessageIterator()
: Collections.emptyIterator();
this.subfolderIterator = (folder.getType() & Folder.HOLDS_FOLDERS) > 0
? new SubfolderIterator()
: Collections.emptyIterator();
}
示例7: getMessage
public void getMessage( cfImapConnection imapConnection, String rootFolder, long messageID, String _attachURI, String _attachDIR ) throws cfmRunTimeException {
try{
Folder folderToList;
if ( rootFolder == null || rootFolder.length() == 0 )
folderToList = imapConnection.mailStore.getDefaultFolder();
else
folderToList = imapConnection.mailStore.getFolder(rootFolder);
if ( (folderToList.getType() & Folder.HOLDS_MESSAGES) != 0){
if ( !folderToList.isOpen() )
folderToList.open( Folder.READ_ONLY );
boolean bResult = false;
if ( folderToList instanceof UIDFolder )
bResult = extractMessage( ((UIDFolder)folderToList).getMessageByUID( messageID ), messageID, _attachURI, _attachDIR );
else
bResult = extractMessage( folderToList.getMessage( (int)messageID ), messageID, _attachURI, _attachDIR );
if ( !bResult ) imapConnection.setStatus( false, "Message does not exist" );
else imapConnection.setStatus( true, "" );
folderToList.close(false);
}
}catch(Exception E){
imapConnection.setStatus( false, E.getMessage() );
}
}
示例8: listFolderMessages
public cfQueryResultData listFolderMessages( cfImapConnection imapConnection, String rootFolder, int startRow, int totalMessages, boolean reverseOrder ) {
cfQueryResultData query = new cfQueryResultData( new String[]{"subject","id","rxddate","sentdate","from","to","cc","bcc","size","lines","answered","deleted","draft","flagged","recent","seen"}, "CFIMAP" );
try{
Folder folderToList;
if ( rootFolder == null || rootFolder.length() == 0 )
folderToList = imapConnection.mailStore.getDefaultFolder();
else
folderToList = imapConnection.mailStore.getFolder(rootFolder);
if ( (folderToList.getType() & Folder.HOLDS_MESSAGES) != 0){
if ( !folderToList.isOpen() )
folderToList.open( Folder.READ_ONLY );
Message[] messageArray;
if ( startRow != -1 ){
int folderCount = folderToList.getMessageCount();
int start, end;
if ( !reverseOrder ){
start = startRow;
if ( folderCount < (startRow+totalMessages-1) ){
start = startRow;
end = folderCount;
}else{
end = startRow + totalMessages - 1;
}
}else{
end = folderCount - startRow + 1;
if ( folderCount < (startRow+totalMessages-1) ){
start = 1;
}else{
start = folderCount - startRow - totalMessages + 2;
}
}
messageArray = folderToList.getMessages( start, end );
imapConnection.setTotalMessages( folderCount );
}else{
messageArray = folderToList.getMessages();
imapConnection.setTotalMessages( messageArray.length );
}
// To improve performance, pre-fetch all of the message items
// used by the CFIMAP list action. This will retrieve all of the
// items for all of the messages with one single FETCH command.
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
fp.add(FetchProfile.Item.FLAGS);
fp.add(FetchProfile.Item.CONTENT_INFO);
folderToList.fetch(messageArray, fp);
List<Map<String, cfData>> vectorMessages = new ArrayList<Map<String, cfData>>(messageArray.length);
if ( reverseOrder ){
int msgIndex = messageArray.length-1;
for (int i = 0; i < messageArray.length; i++)
vectorMessages.add( extractMessage( messageArray[msgIndex--] ) );
}else{
for (int i = 0; i < messageArray.length; i++)
vectorMessages.add( extractMessage( messageArray[i] ) );
}
folderToList.close(false);
query.populateQuery( vectorMessages );
}
}catch(Exception E){
cfEngine.log( E.getMessage() );
imapConnection.setStatus( false, E.getMessage() );
}
return query;
}