當前位置: 首頁>>代碼示例>>Java>>正文


Java Folder.HOLDS_MESSAGES屬性代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:19,代碼來源:JavamailService.java

示例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();
		}
	}
 
開發者ID:mathieulegoc,項目名稱:SmartTokens,代碼行數:18,代碼來源:GmailFolder.java

示例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]);
	}
}
 
開發者ID:Ardulink,項目名稱:Ardulink-1,代碼行數:17,代碼來源:MailListener.java

示例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;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:10,代碼來源:FolderData.java

示例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);
        }
    }
}
 
開發者ID:shashanksingh28,項目名稱:code-similarity,代碼行數:37,代碼來源:MailLister.java

示例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();
}
 
開發者ID:google,項目名稱:mail-importer,代碼行數:13,代碼來源:JavaxMailStorage.java

示例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() );
	}
}
 
開發者ID:OpenBD,項目名稱:openbd-core,代碼行數:30,代碼來源:cfMailMessageData.java

示例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;
}
 
開發者ID:OpenBD,項目名稱:openbd-core,代碼行數:78,代碼來源:cfMailFolderMessagesData.java


注:本文中的javax.mail.Folder.HOLDS_MESSAGES屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。