本文整理汇总了Java中com.sun.mail.imap.IMAPFolder.setFlags方法的典型用法代码示例。如果您正苦于以下问题:Java IMAPFolder.setFlags方法的具体用法?Java IMAPFolder.setFlags怎么用?Java IMAPFolder.setFlags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.mail.imap.IMAPFolder
的用法示例。
在下文中一共展示了IMAPFolder.setFlags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: markMessagesAsRead
import com.sun.mail.imap.IMAPFolder; //导入方法依赖的package包/类
public void markMessagesAsRead(String[] ids, boolean seen) throws NoSuchProviderException, MessagingException, IOException {
IMAPFolder folder = (IMAPFolder)getStore().getFolder("Inbox");
folder.open(Folder.READ_WRITE);
UIDFolder uidFolder = folder;
Message[] msgs;
long[] uids = new long[ids.length];
int i = 0;
for (String s : ids) {
try {
uids[i++] = Long.parseLong(s);
} catch (Exception ex) {
Log.d("rgai", "", ex);
}
}
// TODO: if instance not support UID, then use simple id
msgs = uidFolder.getMessagesByUID(uids);
folder.setFlags(msgs, new Flags(Flags.Flag.SEEN), seen);
folder.close(false);
}
示例2: testSearchNotFlags
import com.sun.mail.imap.IMAPFolder; //导入方法依赖的package包/类
@Test
public void testSearchNotFlags() throws MessagingException {
store.connect("[email protected]", "pwd");
try {
IMAPFolder folder = (IMAPFolder) store.getFolder("INBOX");
folder.open(Folder.READ_WRITE);
folder.setFlags(new int[]{2,3}, new Flags(Flags.Flag.ANSWERED), true);
Response[] ret = (Response[]) folder.doCommand(new IMAPFolder.ProtocolCommand() {
@Override
public Object doCommand(IMAPProtocol protocol) throws ProtocolException {
return protocol.command("SEARCH NOT (ANSWERED) NOT (DELETED) NOT (SEEN) NOT (FLAGGED) ALL", null);
}
});
IMAPResponse response = (IMAPResponse) ret[0];
assertFalse(response.isBAD());
assertEquals("1 4 5 6 7 8 9 10" /* 2 and 3 set to answered */, response.getRest());
} finally {
store.close();
}
}