本文整理汇总了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);
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}