• 大小: 4.12KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-02-01
  • 语言: Java
  • 标签: java  信息  邮件  

资源简介

// 解析所有邮件 for (int i = 0, count = messages.length; i < count; i  ) {
    MimeMessage msg = (MimeMessage) messages[i]; log.info("------------------解析第"  msg.getMessageNumber() "封邮件-------------------- "); log.info("主题: "  getSubject(msg)); log.info("发件人: "  getFrom(msg)); log.info("收件人:"  getReceiveAddress(msg, null)); log.info("发送时间:"  getSentDate(msg, null)); log.info("是否已读:"  isSeen(msg)); log.info("邮件优先级:"  getPriority(msg)); log.info("是否需要回执:"  isReplySign(msg)); log.info("邮件大小:"  msg.getSize() * 1024  "kb"); boolean isContainerAttachment = isContainAttachment(msg); log.info("是否包含附件:"  isContainerAttachment); if (isContainerAttachment) {
        File file = new File(destDir); if (!file.exists()) {
            file.mkdirs();
        } saveAttachment(msg, destDir); //保存附件  }
    StringBuffer content = new StringBuffer(30); getMailTextContent(msg, content); log.info("邮件正文:"  (content.length() > 100 ? content.substring(0, 100) "..." : content)); log.info("------------------"  msg.getMessageNumber() "封邮件解析结束-------------------- ");
}

资源截图

代码片段和文件信息

package com.helld.common.utils;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;

import javax.mail.Address;
import javax.mail.BodyPart;
import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Part;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件       16296  2020-07-21 09:02  POP3ReceiveMailUtils.java

评论

共有 条评论