本文整理汇总了Java中javax.mail.Message.setFlag方法的典型用法代码示例。如果您正苦于以下问题:Java Message.setFlag方法的具体用法?Java Message.setFlag怎么用?Java Message.setFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.mail.Message
的用法示例。
在下文中一共展示了Message.setFlag方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteMails
import javax.mail.Message; //导入方法依赖的package包/类
/**
* Connect to the mail server and delete all mails.
*/
public void deleteMails() throws MessagingException {
Folder folder = getStore().getFolder(MAIL_INBOX);
folder.open(Folder.READ_WRITE);
// Get folder's list of messages.
Message[] messages = folder.getMessages();
// Retrieve message headers for each message in folder.
FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.ENVELOPE);
folder.fetch(messages, profile);
for (Message message : messages) {
message.setFlag(Flags.Flag.DELETED, true);
}
folder.close(true);
}
示例2: getAllMetaData
import javax.mail.Message; //导入方法依赖的package包/类
public List<MetaData> getAllMetaData() throws RbvException {
//first check if the folder is open
if (!isOpen) {
throw new MatchableNotOpenException(getDescription() + " is not open");
}
try {
allMetaDataList.clear();
newMetaDataList.clear();
boolean hasNew = folder.hasNewMessages();
log.debug("Has new messages in folder: " + hasNew);
Message[] imapMessages = folder.getMessages();
for (Message imapMessage : imapMessages) {
ImapMetaData currentMeta = createImapMetaData((MimeMessage) imapMessage);
if (currentMeta != null) {
if (!imapMessage.getFlags().contains(Flags.Flag.FLAGGED)) {
newMetaDataList.add(currentMeta);
}
imapMessage.setFlag(Flags.Flag.FLAGGED, true);
allMetaDataList.add(currentMeta);
}
}
//this was the first pass
isInitialPass = false;
return allMetaDataList;
} catch (MessagingException me) {
throw new RbvStorageException("Could not get meta data from " + getDescription(), me);
}
}
示例3: getNewMetaData
import javax.mail.Message; //导入方法依赖的package包/类
public List<MetaData> getNewMetaData() throws RbvException {
//first check if the folder is open
if (!isOpen) {
throw new MatchableNotOpenException(getDescription() + " is not open");
}
if (isInitialPass) {
isInitialPass = false;
return getAllMetaData();
}
try {
newMetaDataList.clear();
Message[] imapMessages = folder.getMessages();
for (Message imapMessage : imapMessages) {
if (!imapMessage.getFlags().contains(Flags.Flag.FLAGGED)) {
imapMessage.setFlag(Flags.Flag.FLAGGED, true);
ImapMetaData currentMeta = createImapMetaData((MimeMessage) imapMessage);
if (currentMeta != null) {
allMetaDataList.add(currentMeta);
newMetaDataList.add(currentMeta);
}
}
}
} catch (MessagingException me) {
throw new RbvStorageException("Could not get meta data from " + getDescription(), me);
}
return newMetaDataList;
}
示例4: readPassAndKeyFromEmail
import javax.mail.Message; //导入方法依赖的package包/类
public String[] readPassAndKeyFromEmail(boolean delete, String userName)
throws MessagingException {
// Download message headers from server.
int retries = 0;
String userPass = null;
String userKey = null;
while (retries < 40 && userPass == null) {
// Open main "INBOX" folder.
Folder folder = getStore().getFolder(MAIL_INBOX);
folder.open(Folder.READ_WRITE);
// Get folder's list of messages.
Message[] messages = folder.getMessages();
// Retrieve message headers for each message in folder.
FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.ENVELOPE);
folder.fetch(messages, profile);
for (Message message : messages) {
if (message.getSubject().equals(MAIL_SUBJECT_USER_ACCOUNT_CREATED_EN)) {
String content = getMessageContent(message);
String userNameFromEmail = readInformationFromGivenMail(MAIL_BODY_USERNAME_PATTERN_EN, content);
if (userName.equals(userNameFromEmail)) {
userKey = readInformationFromGivenMail(MAIL_BODY_USERKEY_PATTERN_EN, content);
userPass = readInformationFromGivenMail(MAIL_BODY_PASSWORD_PATTERN_EN, content);
if (delete) {
message.setFlag(Flag.DELETED, true);
}
break;
}
}
}
folder.close(true);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// ignored
}
retries++;
}
return new String[] {userKey, userPass};
}
示例5: check
import javax.mail.Message; //导入方法依赖的package包/类
public void check(Message message, ReciveMail mail) throws Exception {
String from = mail.getFrom().trim();
String subject = mail.getSubject().trim();
List<String> allowMails = Arrays.asList(PropertyUtil.getProperties("audit.allow.mail").split(","));
if (!from.equals(EmailUtil.sender) && !allowMails.contains(from)) {
logger.warn("{}没有审批权限", from);
logger.info("审核人无权限, 删除邮件: {}", subject);
message.setFlag(Flags.Flag.DELETED, true);
return;
}
String content = mail.getBodyText();
if (content != null) {
content = content.replaceAll(HTMLTAG, "");
String[] lines = content.split("\r\n");
for (int i = 0; i < lines.length; i++) {
String line = lines[i];
if (StringUtils.hasText(line)) {
line = line.trim();
if (line.equals("同意") || line.toUpperCase().equals("OK")
|| line.substring(0, 2).equals("同意")
|| line.toUpperCase().substring(0, 2).equals("OK")
) {
if (doAudit(mail, null)) {
logger.info("审核完毕, 删除邮件 {}", subject);
message.setFlag(Flags.Flag.DELETED, true);
}
} else if (line.equals("不同意") || line.toUpperCase().equals("NO")
|| line.substring(0, 3).equals("不同意")
|| line.toUpperCase().substring(0, 2).equals("NO")
) {
String [] msgs = line.split(":");
String rejectReason = "";
if (msgs != null && msgs.length >= 2) {
rejectReason = msgs[1];
rejectReason = com.ipd.jsf.worker.util.StringUtils.filterString(rejectReason);
}
if (rejectReason == null) {
rejectReason = "";
}
if (doAudit(mail, rejectReason)) {
logger.info("驳回完毕, 删除邮件 {}", subject);
message.setFlag(Flags.Flag.DELETED, true);
}
} else {
logger.warn("邮件: {}的审批内容:[{}]格式错误, 请回复'同意'或者'OK'", subject, line);
logger.info("删除邮件: {}", subject);
message.setFlag(Flags.Flag.DELETED, true);
}
break;
}
}
}
}