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


Java Folder.setFlags方法代碼示例

本文整理匯總了Java中javax.mail.Folder.setFlags方法的典型用法代碼示例。如果您正苦於以下問題:Java Folder.setFlags方法的具體用法?Java Folder.setFlags怎麽用?Java Folder.setFlags使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.mail.Folder的用法示例。


在下文中一共展示了Folder.setFlags方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deleteMails

import javax.mail.Folder; //導入方法依賴的package包/類
/**
    * delete all message in ibox that match given criteria
    * @param messageNumbers
    * @param uIds
    * @throws MessagingException
 * @throws IOException 
    */
   public void deleteMails(String as[], String as1[]) throws MessagingException, IOException {
	Folder folder;
	Message amessage[];
	folder = _fldelse.getFolder("INBOX");
	folder.open(2);
	Map<String, Message> map = getMessages(null,folder, as1, as, startrow, maxrows,false);
	Iterator<String> iterator = map.keySet().iterator();
	amessage = new Message[map.size()];
	int i = 0;
	while(iterator.hasNext()) {
		amessage[i++] =  map.get(iterator.next());
	}
	try {
		folder.setFlags(amessage, new Flags(javax.mail.Flags.Flag.DELETED), true);
	}
	finally {
		folder.close(true);
	}
}
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:27,代碼來源:MailClient.java

示例2: deleteMessage

import javax.mail.Folder; //導入方法依賴的package包/類
private void deleteMessage(Message toDelete) {
    if (toDelete != null) {
        try {
            final Folder source = toDelete.getFolder();
            source.setFlags(new Message[]{toDelete}, FLAGS_DELETED, true);
            deleteCount++;
        } catch (MessagingException ex) {
            throw new RuntimeException(ex);
        }
    }
}
 
開發者ID:PacktPublishing,項目名稱:Java-9-Programming-Blueprints,代碼行數:12,代碼來源:AccountProcessor.java

示例3: moveMessage

import javax.mail.Folder; //導入方法依賴的package包/類
private void moveMessage(Message toMove, Folder dest) {
    if (toMove != null) {
        try {
            final Folder source = toMove.getFolder();
            final Message[] messages = new Message[]{toMove};
            source.setFlags(messages, FLAGS_DELETED, true);
            source.copyMessages(messages, dest);
            moveCount++;
        } catch (MessagingException ex) {
            throw new RuntimeException(ex);
        }
    }
}
 
開發者ID:PacktPublishing,項目名稱:Java-9-Programming-Blueprints,代碼行數:14,代碼來源:AccountProcessor.java

示例4: checkEmail

import javax.mail.Folder; //導入方法依賴的package包/類
/**
 * Check the inbox for new messages, and process each message.
 */
public void checkEmail() {
	try {
		log("Checking email.", Level.INFO);
        Store store = connectStore();		
	    Folder inbox = store.getFolder("INBOX");
	    if (inbox == null) {
	      throw new BotException("Failed to check email, no INBOX.");
	    }
	    inbox.open(Folder.READ_WRITE);
           Message[] messages = inbox.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
           inbox.setFlags(messages, new Flags(Flags.Flag.SEEN), true);
	    //Message[] messages = inbox.getMessages();
	    if ((messages != null) && (messages.length > 0)) {
   			log("Processing emails", Level.INFO, messages.length);
			Network memory = getBot().memory().newMemory();
			Vertex sense = memory.createVertex(getPrimitive());
			Vertex vertex = sense.getRelationship(Primitive.LASTMESSAGE);
			long lastMessage = 0;
			if (vertex != null) {
				lastMessage = ((Number)vertex.getData()).longValue();
			}
			long maxMessage = 0;
			int count = 0;
			// Increase script timeout.
			Language language = getBot().mind().getThought(Language.class);
			int timeout = language.getMaxStateProcess();
			language.setMaxStateProcess(timeout * 2);
			try {
			    for (int index = 0; index < messages.length; index++) {
			    	if (index > (this.maxEmails * 2)) {
		    			log("Max old email limit reached", Level.WARNING, this.maxEmails * 2);
			    		break;
			    	}
			    	long recievedTime = 0;
			    	if (messages[index].getReceivedDate() == null) {
		    			log("Missing received date", Level.FINE, messages[index].getSubject());
			    		recievedTime = messages[index].getSentDate().getTime();
			    	} else {
			    		recievedTime = messages[index].getReceivedDate().getTime();
			    	}
			    	if ((System.currentTimeMillis() - recievedTime) > DAY) {
						log("Day old email", Level.INFO, messages[index].getSubject());
			    		continue;
			    	}
			    	if (recievedTime > lastMessage) {
			    		count++;
			    		if (count > this.maxEmails) {
			    			log("Max email limit reached", Level.WARNING, this.maxEmails);
			    			break;
			    		}
			    		input(messages[index]);
				    	Utils.sleep(100);
				    	if (recievedTime > maxMessage) {
				    		maxMessage = recievedTime;
				    	}
			    	}
			    }
			    if (maxMessage != 0) {
					sense.setRelationship(Primitive.LASTMESSAGE, memory.createVertex(maxMessage));
			    	memory.save();
			    }
			} finally {
				language.setMaxStateProcess(timeout);
			}
	    }
		log("Done checking email.", Level.INFO);
	    inbox.close(false);
	    store.close();
	} catch (MessagingException exception) {
		log(exception);
	}
}
 
開發者ID:BotLibre,項目名稱:BotLibre,代碼行數:76,代碼來源:Email.java


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