Java Code Examples for javax.mail.internet.MimeMessage#getReceivedDate()
The following examples show how to use
javax.mail.internet.MimeMessage#getReceivedDate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommonServices.java From scipio-erp with Apache License 2.0 | 6 votes |
public static Map<String, Object> mcaTest(DispatchContext dctx, Map<String, ?> context) { MimeMessageWrapper wrapper = (MimeMessageWrapper) context.get("messageWrapper"); MimeMessage message = wrapper.getMessage(); try { if (message.getAllRecipients() != null) { Debug.logInfo("To: " + UtilMisc.toListArray(message.getAllRecipients()), module); } if (message.getFrom() != null) { Debug.logInfo("From: " + UtilMisc.toListArray(message.getFrom()), module); } Debug.logInfo("Subject: " + message.getSubject(), module); if (message.getSentDate() != null) { Debug.logInfo("Sent: " + message.getSentDate().toString(), module); } if (message.getReceivedDate() != null) { Debug.logInfo("Received: " + message.getReceivedDate().toString(), module); } } catch (Exception e) { Debug.logError(e, module); } return ServiceUtil.returnSuccess(); }
Example 2
Source File: Pop3Util.java From anyline with Apache License 2.0 | 5 votes |
/** * 解析邮件 * @param setRead setRead * @param delete delete * @param messages 要解析的邮件列表 * @return return */ public List<Mail> parse( boolean setRead, boolean delete, Message... messages){ List<Mail> mails = new ArrayList<Mail>(); try{ for (Message item:messages) { Mail mail = new Mail(); MimeMessage msg = (MimeMessage) item; Date sendTime = msg.getSentDate(); Date receiveTime = msg.getReceivedDate(); String subject = msg.getSubject(); boolean isSeen = isSeen(msg); boolean isContainerAttachment = isContainAttachment(msg); log.info("[解析邮件][subject:{}][发送时间:{}][是否已读:{}][是否包含附件:{}]",subject,DateUtil.format(sendTime),isSeen,isContainerAttachment); mail.setSubject(subject); mail.setSendTime(sendTime); mail.setReceiveTime(receiveTime); if(config.AUTO_DOWNLOAD_ATTACHMENT){ if (isContainerAttachment) { String dir = config.ATTACHMENT_DIR.replace("{ymd}", DateUtil.format(sendTime,"yyyyMMdd")); List<File> attachments = downloadAttachment(msg, dir , sendTime, null); mail.setAttachments(attachments); } } if(!isSeen && setRead){ seen(msg); } if(delete){ delete(msg); } mails.add(mail); } }catch(Exception e){ e.printStackTrace(); } return mails; }