当前位置: 首页>>代码示例>>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;未经允许,请勿转载。