「java邮件解析」java邮件附件解析

博主:adminadmin 2023-01-02 21:30:12 799

本篇文章给大家谈谈java邮件解析,以及java邮件附件解析对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

java邮件服务器怎么解析邮件

用户连上邮件服务器后,要想给它发送一封电子邮件,需要遵循一定的通迅规则,SMTP协议就是用于定义这种通讯规则的。

因而,通常我们也把处理用户smtp请求(邮件发送请求)的邮件服务器称之为SMTP服务器。(25)

2.POP3协议

同样,用户若想从邮件服务器管理的电子邮箱中接收一封电子邮件的话,他连上邮件服务器后,也需要遵循一定的通迅格式,POP3协议用于定义这种通讯格式。

因而,通常我们也把处理用户pop3请求(邮件接收请求)的邮件服务器称之为POP3服务器。(110

java 解析 eml的源代码

// 从EML文件得到MimeMessage对象

MimeMessage message = new MimeMessage(session, new FileInputStream(emlFile));

public static String getMailSubject(Message message) throws Exception {

return MimeUtility.decodeText(message.getSubject());

}

public static String getMailSender(Message message) throws Exception {

String emailSender = null;

Address[] addresses = message.getFrom();

if (addresses == null || addresses.length  1) {

throw new IllegalArgumentException("该邮件没有发件人");

}

// 获得发件人

InternetAddress address = (InternetAddress) addresses[0];

String senderName = address.getPersonal();

if (senderName != null) {

senderName = MimeUtility.decodeText(senderName);

emailSender = senderName + "" + address.getAddress() + "";

} else {

senderName = address.getAddress();

}

return emailSender;

}

public static String getMailRecipients(Message message, Message.RecipientType recipientType) throws Exception {

StringBuilder builder = new StringBuilder();

Address[] addresses = null;

if (recipientType == null) {

addresses = message.getAllRecipients();

} else {

addresses = message.getRecipients(recipientType);

}

if (addresses == null || addresses.length  1) {

throw new IllegalArgumentException("该邮件没有收件人");

}

for (Address address : addresses) {

InternetAddress iAddress = (InternetAddress) address;

builder.append(iAddress.toUnicodeString()).append(", ");

}

return builder.deleteCharAt(builder.length() - 1).toString();

}

public static String getMailSendDate(Message message, String pattern) throws Exception {

String sendDateString = null;

if (pattern == null || "".equals(pattern.trim())) {

pattern = "yyyy年MM月dd日 E HH:mm";

}

Date sendDate = message.getSentDate();

sendDateString = new SimpleDateFormat(pattern).format(sendDate);

return sendDateString;

}

public static boolean containsAttachment(Part part) throws Exception {

boolean flag = false;

if (part != null) {

if (part.isMimeType("multipart/*")) {

MimeMultipart mp = (MimeMultipart) part.getContent();

for (int i = 0; i  mp.getCount(); i++) {

BodyPart bodyPart = mp.getBodyPart(i);

String disposition = bodyPart.getDisposition();

if (disposition != null  (Part.ATTACHMENT.equalsIgnoreCase(disposition)

|| Part.INLINE.equalsIgnoreCase(disposition))) {

flag = true;

} else if (bodyPart.isMimeType("multipart/*")) {

flag = containsAttachment(bodyPart);

} else {

String contentType = bodyPart.getContentType();

if (contentType.indexOf("application") != -1) {

flag = true;

}

if (contentType.indexOf("name") != -1) {

flag = true;

}

}

if (flag)

break;

}

} else if (part.isMimeType("message/rfc822")) {

flag = containsAttachment((Part) part.getContent());

}

}

return flag;

}

public static boolean isSeen(Message message) throws Exception {

if (message == null) {

throw new MessagingException("Message is empty");

}

return message.getFlags().contains(Flags.Flag.SEEN);

}

public static boolean isReplaySign(Message message) throws Exception {

if (message == null) {

throw new MessagingException("Message is empty");

}

boolean replaySign = false;

String[] headers = message.getHeader("Disposition-Notification-To");

if (headers != null  headers.length  0) {

replaySign = true;

}

return replaySign;

}

public static String getMailPriority(Message message) throws Exception {

if (message == null) {

throw new MessagingException("Message is empty");

}

String priority = "普通";

String[] headers = message.getHeader("X-Priority");

if (headers != null  headers.length  0) {

String mailPriority = headers[0];

if (mailPriority.indexOf("1") != -1 || mailPriority.indexOf("High") != -1) {

priority = "紧急";

} else if (mailPriority.indexOf("5") != -1 || mailPriority.indexOf("Low") != -1) {

priority = "低";

} else {

priority = "普通"; // 3或者Normal;

}

}

return priority;

}

public static void getMailTextContent(Part part, StringBuilder content) throws Exception {

if (part == null) {

throw new MessagingException("Message content is empty");

}

boolean containsTextInAttachment = part.getContentType().indexOf("name")  0;

if (part.isMimeType("text/*")  containsTextInAttachment) {

content.append(part.getContent().toString());

} else if (part.isMimeType("message/rfc822")) {

getMailTextContent((Part) part.getContent(), content);

} else if (part.isMimeType("multipart/*")) {

Multipart mp = (Multipart) part.getContent();

for (int i = 0; i  mp.getCount(); i++) {

BodyPart bodyPart = mp.getBodyPart(i);

getMailTextContent(bodyPart, content);

}

} else if (part.isMimeType("image/*")) {

// TODO part.getInputStream()获得输入流然后输出到指定的目录

} else {

// TODO 其它类型的contentType, 未做处理, 直接输出

content.append(part.getContent().toString());

}

}

public static void saveAttachment(Part part, String destDir) throws Exception {

if (part == null) {

throw new MessagingException("part is empty");

}

// 复杂的邮件包含多个邮件体

if (part.isMimeType("multipart/*")) {

Multipart mp = (Multipart) part.getContent();

// 遍历每一个邮件体

for (int i = 0; i  mp.getCount(); i++) {

BodyPart bodyPart = mp.getBodyPart(i);

// bodyPart也可能有多个邮件体组成

String disposition = bodyPart.getDisposition();

if (disposition == null  (Part.ATTACHMENT.equalsIgnoreCase(disposition)

|| Part.INLINE.equalsIgnoreCase(disposition))) {

InputStream in = bodyPart.getInputStream();

saveFile(in, destDir, decodeText(bodyPart.getFileName()));

} else if (bodyPart.isMimeType("multipart/*")) {

saveAttachment(bodyPart, destDir);

} else {

String contentType = bodyPart.getContentType();

if (contentType.indexOf("name") != -1 || contentType.indexOf("application") != -1) {

saveFile(bodyPart.getInputStream(), destDir, decodeText(bodyPart.getFileName()));

}

}

}

} else if (part.isMimeType("message/rfc822")) {

saveAttachment((Part) part.getContent(), destDir);

}

}

public static void saveFile(InputStream in, String destDir, String fileName) throws Exception {

FileOutputStream out = new FileOutputStream(new File(destDir + fileName));

byte[] buffer = new byte[1024];

int length = 0;

while ((length = in.read(buffer)) != -1) {

out.write(buffer, 0, length);

}

out.close();

in.close();

}

public static String decodeText(String encodedText) throws Exception {

if (encodedText == null || "".equals(encodedText.trim())) {

return "";

} else {

return MimeUtility.decodeText(encodedText);

}

}

java邮件中验证的解释

JAVAMAIL结合邮件服务的时候 用的

Properties props = System.getProperties();// 创建Properties 对象

// 添加smtp服务器属性

props.put("mail.smtp.host", host);

props.put("mail.smtp.auth", "true"); // 需要验证

props.put("mail.transport.protocol", "smtp");

首先是先由这个props 对象 然后根据这个对象的host找到你要用的邮件服务 如果配163的域名 就找163的邮件服务 如果是本地的 就找本地的 然后打开Session

下一步就可以传 用户名和密码到邮件服务里面去了

returnnew PasswordAuthentication(userName, password); 就是这里

如果邮件服务里面有你的这个用户名 密码也是对的 就成功打开Session

// 定义邮件信息

MimeMessage message = new MimeMessage(session);

吧Session和邮件服务绑定

开始在 message里面写入你的邮件 。。。

session.getTransport("smtp").send(message); 最后 指定SMTP 的方式 吧你的邮件发送出去

整个过程就是这样 关于原理 你可以看你的发送邮件的类 一步一个过程 很容易就明白了

javamail接收邮件怎么解析内容

package com.ghy.util;

import java.io.BufferedInputStream;

import java.io.BufferedOutputStream;

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStream;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Properties;

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.MimeUtility;

public class PraseMimeMessage{

private MimeMessage mimeMessage=null;

private String saveAttachPath="";//附件下载后的存放目录

private StringBuffer bodytext=new StringBuffer();

//存放邮件内容的StringBuffer对象

private String dateformat="yy-MM-dd HH:mm";//默认的日前显示格式

/**

 * 构造函数,初始化一个MimeMessage对象

 */

public PraseMimeMessage() {

}

public PraseMimeMessage(MimeMessage mimeMessage) {

this.mimeMessage=mimeMessage;

}

public void setMimeMessage(MimeMessage mimeMessage){

this.mimeMessage=mimeMessage;

}

/**

 * 获得发件人的地址和姓名

 */

public String getFrom1()throws Exception{

InternetAddress address[]=(InternetAddress[])mimeMessage.getFrom();

String from=address[0].getAddress();

if(from==null){

from="";

}

String personal=address[0].getPersonal();

if(personal==null){

personal="";

}

String fromaddr=personal+""+from+"";

return fromaddr;

}

/**

 * 获得邮件的收件人,抄送,和密送的地址和姓名,根据所传递的参数的不同

 * "to"----收件人 "cc"---抄送人地址 "bcc"---密送人地址  

* @throws Exception */

public String getMailAddress(String type){

String mailaddr="";

try {

String addtype=type.toUpperCase();

InternetAddress []address=null;

if(addtype.equals("TO")||addtype.equals("CC")||addtype.equals("BBC")){

if(addtype.equals("TO")){

address=(InternetAddress[])mimeMessage.getRecipients(Message.RecipientType.TO);

}

else if(addtype.equals("CC")){

address=(InternetAddress[])mimeMessage.getRecipients(Message.RecipientType.CC);

}

else{

address=(InternetAddress[])mimeMessage.getRecipients(Message.RecipientType.BCC);

}

if(address!=null){

for (int i = 0; i address.length; i++) {

String email=address[i].getAddress();

if(email==null)email="";

else{

email=MimeUtility.decodeText(email);

}

String personal=address[i].getPersonal();

if(personal==null)personal="";

else{

personal=MimeUtility.decodeText(personal);

}

String compositeto=personal+""+email+"";

mailaddr+=","+compositeto;

}

mailaddr=mailaddr.substring(1);

}

}

else{

}

} catch (Exception e) {

// TODO: handle exception

}

return mailaddr;

}

/**

* 获得邮件主题

*/

public String getSubject()

{

String subject="";

try {

subject=MimeUtility.decodeText(mimeMessage.getSubject());

if(subject==null)subject="";

} catch (Exception e) {

// TODO: handle exception

}

return subject;

}

/**

* 获得邮件发送日期

*/

public String getSendDate()throws Exception{

Date senddate=mimeMessage.getSentDate();

SimpleDateFormat format=new SimpleDateFormat(dateformat);

return format.format(senddate);

}

/**

* 解析邮件,把得到的邮件内容保存到一个StringBuffer对象中,解析邮件

* 主要是根据MimeType类型的不同执行不同的操作,一步一步的解析

*/

public void getMailContent(Part part)throws Exception{

String contenttype=part.getContentType();

int nameindex=contenttype.indexOf("name");

boolean conname=false;

if(nameindex!=-1)conname=true;

if(part.isMimeType("text/plain")!conname){

bodytext.append((String)part.getContent());

}else if(part.isMimeType("text/html")!conname){

bodytext.append((String)part.getContent());

}

else if(part.isMimeType("multipart/*")){

Multipart multipart=(Multipart)part.getContent();

int counts=multipart.getCount();

for(int i=0;icounts;i++){

getMailContent(multipart.getBodyPart(i));

}

}else if(part.isMimeType("message/rfc822")){

getMailContent((Part)part.getContent());

}

else{}

}

/**

 * 获得邮件正文内容

*/

public String getBodyText(){

return bodytext.toString();

}

/**

* 判断此邮件是否需要回执,如果需要回执返回"true",否则返回"false"

* @throws MessagingException */

public boolean getReplySign() throws MessagingException{

boolean replysign=false;

String needreply[]=mimeMessage.getHeader("Disposition-Notification-To");

if(needreply!=null){

replysign=true;

}

return replysign;

}

/**

 * 获得此邮件的Message-ID

* @throws MessagingException */

public String getMessageId() throws MessagingException{

return mimeMessage.getMessageID();

}

/**

 * 【判断此邮件是否已读,如果未读返回返回false,反之返回true】

* @throws MessagingException */

public boolean isNew() throws MessagingException{

boolean isnew =false;

Flags flags=((Message)mimeMessage).getFlags();

Flags.Flag[]flag=flags.getSystemFlags();

for (int i = 0; i flag.length; i++) {

if(flag[i]==Flags.Flag.SEEN){

isnew=true;

break;

}

}

return isnew;

}

/**

 * 判断此邮件是否包含附件  

* @throws MessagingException */

public boolean isContainAttach(Part part) throws Exception{

boolean attachflag=false;

String contentType=part.getContentType();

if(part.isMimeType("multipart/*")){

Multipart mp=(Multipart)part.getContent();

//获取附件名称可能包含多个附件

for(int j=0;jmp.getCount();j++){

BodyPart mpart=mp.getBodyPart(j);

String disposition=mpart.getDescription();

if((disposition!=null)((disposition.equals(Part.ATTACHMENT))||(disposition.equals(Part.INLINE)))){

attachflag=true;

}else if(mpart.isMimeType("multipart/*")){

attachflag=isContainAttach((Part)mpart);

}else{

String contype=mpart.getContentType();

if(contype.toLowerCase().indexOf("application")!=-1) attachflag=true;

if(contype.toLowerCase().indexOf("name")!=-1) attachflag=true;

}

}

}else if(part.isMimeType("message/rfc822")){

attachflag=isContainAttach((Part)part.getContent());

}

return attachflag;

}

/**

 * 【保存附件】  

* @throws Exception

* @throws IOException

* @throws MessagingException

* @throws Exception */

public void saveAttachMent(Part part) throws Exception {

String fileName="";

if(part.isMimeType("multipart/*")){

Multipart mp=(Multipart)part.getContent();

for(int j=0;jmp.getCount();j++){

BodyPart mpart=mp.getBodyPart(j);

String disposition=mpart.getDescription();

if((disposition!=null)((disposition.equals(Part.ATTACHMENT))||(disposition.equals(Part.INLINE)))){

fileName=mpart.getFileName();

if(fileName.toLowerCase().indexOf("GBK")!=-1){

fileName=MimeUtility.decodeText(fileName);

}

saveFile(fileName,mpart.getInputStream());

}

else if(mpart.isMimeType("multipart/*")){

fileName=mpart.getFileName();

}

else{

fileName=mpart.getFileName();

if((fileName!=null)){

fileName=MimeUtility.decodeText(fileName);

saveFile(fileName,mpart.getInputStream());

}

}

}

}

else if(part.isMimeType("message/rfc822")){

saveAttachMent((Part)part.getContent());

}

}

/**

 * 【设置附件存放路径】

 */

public void setAttachPath(String attachpath){

this.saveAttachPath=attachpath;

}

/**

 * 【设置日期显示格式】

 */

public void setDateFormat(String format){

this.dateformat=format;

}

/**

 * 【获得附件存放路径】

 */

public String getAttachPath()

{

return saveAttachPath;

}

/**

 * 【真正的保存附件到指定目录里】

 */

private void saveFile(String fileName,InputStream in)throws Exception{

String osName=System.getProperty("os.name");

String storedir=getAttachPath();

String separator="";

if(osName==null)osName="";

if(osName.toLowerCase().indexOf("win")!=-1){

//如果是window 操作系统

separator="/";

if(storedir==null||storedir.equals(""))storedir="c:\tmp";

}

else{

//如果是其他的系统

separator="/";

storedir="/tmp";

}

File strorefile=new File(storedir+separator+fileName);

BufferedOutputStream bos=null;

BufferedInputStream bis=null;

try {

bos=new BufferedOutputStream(new FileOutputStream(strorefile));

bis=new BufferedInputStream(in);

int c;

while((c=bis.read())!=-1){

bos.write(c);

bos.flush();

}

} catch (Exception e) {

// TODO: handle exception

}finally{

bos.close();

bis.close();

}

}

/**

 * PraseMimeMessage类测试

 

* @throws Exception */

public static void main(String[] args) throws Exception {

String host="pop3.sina.com.cn";

String username="guohuaiyong70345";

String password="071120";

Properties props=new Properties();

Session session=Session.getDefaultInstance(props,null);

Store store=session.getStore("pop3");

store.connect(host,username,password);

Folder folder=store.getFolder("INBOX");

folder.open(Folder.READ_ONLY);

Message message[]=folder.getMessages();

PraseMimeMessage pmm=null;

for (int i = 0; i message.length; i++) {

System.out.println("****************************************第"+(i+1)+"封邮件**********************************");

pmm=new PraseMimeMessage((MimeMessage)message[i]);

System.out.println("主题 :"+pmm.getSubject());

pmm.setDateFormat("yy年MM月dd日 HH:mm");

System.out.println("发送时间 :"+pmm.getSendDate());

System.out.println("是否回执 :"+pmm.getReplySign());

System.out.println("是否包含附件 :"+pmm.isContainAttach((Part)message[i]));

System.out.println("发件人 :"+pmm.getFrom1());

System.out.println("收件人 :"+pmm.getMailAddress("TO"));

System.out.println("抄送地址 :"+pmm.getMailAddress("CC"));

System.out.println("密送地址 :"+pmm.getMailAddress("BCC"));

System.out.println("邮件ID :"+i+":"+pmm.getMessageId());

pmm.getMailContent((Part)message[i]); //根据内容的不同解析邮件

pmm.setAttachPath("c:/tmp/mail"); //设置邮件附件的保存路径

pmm.saveAttachMent((Part)message[i]); //保存附件

System.out.println("邮件正文 :"+pmm.getBodyText());

System.out.println("*********************************第"+(i+1)+"封邮件结束*************************************");

}

}

}

java实现 sbd格式邮件附件的解析?就是读取sbd格式的附件内容

文件类型:办事处会计公司数据文件

类别:数据文件

软件:可打开SBD文件的软件: Microsoft Office Accounting, Superbase Classic, Superbase Scientific, Superbase SB Next Generation Workbench.

关于javaMail ,解析附件,出现奇葩错误 java.io.IOException: A7 BAD Parse command error,

import java.io.FileOutputStream; 

import java.io.IOException; 

import java.util.Properties;

import javax.mail.Address; 

import javax.mail.BodyPart; 

import javax.mail.FetchProfile; 

import javax.mail.Flags; 

import javax.mail.Folder; 

import javax.mail.Message; 

import javax.mail.MessagingException; 

import javax.mail.Multipart; 

import javax.mail.NoSuchProviderException; 

import javax.mail.Part; 

import javax.mail.Session; 

import javax.mail.Store; 

import javax.mail.internet.InternetAddress; 

import javax.mail.internet.MimeMultipart;

/** 

* 邮件接受测试 

*/ 

public class POP3MailReceiverTest {

    public POP3MailReceiverTest() { 

        try { 

            // 1. 设置连接信息, 生成一个 Session 

            Properties props = new Properties(); 

            props.put("mail.transport.protocol", "pop3");// POP3 收信协议 

            props.put("mail.pop.port", "110"); 

            // props.put("mail.debug", "true");// 调试

            Session session = Session.getInstance(props);

            // 2. 获取 Store 并连接到服务器 

            Store store = session.getStore("pop3"); 

            store.connect("localhost", "hp@earth.org", "1234"); 

            // 3. 通过 Store 打开默认目录 Folder 

            Folder folder = store.getDefaultFolder();// 默认父目录 

            if (folder == null) {

                System.out.println("服务器不可用"); 

                return; 

                // System.exit(1); 

            }

//            System.out.println("默认信箱名:" + folder.getName()); 

// 

//            Folder[] folders = folder.list();// 默认目录列表 

// 

//            System.out.println("默认目录下的子目录数: " + folders.length);

            Folder popFolder = folder.getFolder("INBOX");// 获取收件箱 

            popFolder.open(Folder.READ_WRITE);// 可读邮件,可以删邮件的模式打开目录 

            // 4. 列出来收件箱 下所有邮件 

            Message[] messages = popFolder.getMessages(); 

            // 取出来邮件数 

            int msgCount = popFolder.getMessageCount(); 

            System.out.println("共有邮件: " + msgCount + "封");

            // FetchProfile fProfile = new FetchProfile();// 选择邮件的下载模式, 

            // 根据网速选择不同的模式 

            // fProfile.add(FetchProfile.Item.ENVELOPE); 

            // folder.fetch(messages, fProfile);// 选择性的下载邮件

            // 5. 循环处理每个邮件并实现邮件转为新闻的功能 

            for (int i = 0; i  msgCount; i++) { 

                Message msg = messages[i];// 单个邮件 

                // 发件人信息 

                Address[] froms = msg.getFrom(); 

                if(froms != null) { 

                    System.out.println("发件人信息:" + froms[0]); 

                    InternetAddress addr = (InternetAddress)froms[0]; 

                    System.out.println("发件人地址:" + addr.getAddress()); 

                    System.out.println("发件人显示名:" + addr.getPersonal()); 

                } 

                News news = new News();// 生成新闻对象 

                System.out.println("邮件主题:" + msg.getSubject()); 

                news.setTitle(msg.getSubject());

                // getContent() 是获取包裹内容, Part 相当于外包装 

                Multipart multipart = (Multipart) msg.getContent();// 获取邮件的内容, 就一个大包裹, 

                                                                // MultiPart 

                                                                    // 包含所有邮件内容(正文+附件) 

                System.out.println("邮件共有" + multipart.getCount() + "部分组成");

                // 依次处理各个部分 

                for (int j = 0, n = multipart.getCount(); j  n; j++) { 

                    System.out.println("处理第" + j + "部分"); 

                    Part part = multipart.getBodyPart(j);//解包, 取出 MultiPart的各个部分, 每部分可能是邮件内容, 

                    // 也可能是另一个小包裹(MultipPart)

                    // 判断此包裹内容是不是一个小包裹, 一般这一部分是 正文 Content-Type: multipart/alternative 

                    if (part.getContent() instanceof Multipart) { 

                        Multipart p = (Multipart) part.getContent();// 转成小包裹 

                        System.out.println("小包裹中有" + p.getCount() + "部分"); 

                        // 列出小包裹中所有内容 

                        for (int k = 0; k  p.getCount(); k++) { 

                            System.out.println("小包裹内容:" + p.getBodyPart(k).getContent()); 

                            System.out.println("内容类型:" 

                                    + p.getBodyPart(k).getContentType()); 

                            if(p.getBodyPart(k).getContentType().startsWith("text/plain")) { 

                                // 处理文本正文 

                                news.setBody(p.getBodyPart(k).getContent() + ""); 

                            } else { 

                                // 处理 HTML 正文 

                                news.setBody(p.getBodyPart(k).getContent() + ""); 

                            } 

                        } 

                    }

                    // Content-Disposition: attachment;    filename="String2Java.jpg" 

                    String disposition = part.getDisposition();// 处理是否为附件信息 

                    if (disposition != null) {

                        System.out.println("发现附件: " + part.getFileName()); 

                        System.out.println("内容类型: " + part.getContentType()); 

                        System.out.println("附件内容:" + part.getContent()); 

                        java.io.InputStream in = part.getInputStream();// 打开附件的输入流 

                        // 读取附件字节并存储到文件中 

                        java.io.FileOutputStream out = new FileOutputStream(part.getFileName()); 

                        int data; 

                        while((data = in.read()) != -1) { 

                            out.write(data); 

                        } 

                        in.close(); 

                        out.close(); 

                    } 

                } 

                // } 

                // TODO newsDAO.save(news); // 将邮件所携带的信息作为新闻存储起来

                // 6. 删除单个邮件, 标记一下邮件需要删除, 不会真正执行删除操作 

                // msg.setFlag(Flags.Flag.DELETED, true); 

            }

            // 7. 关闭 Folder 会真正删除邮件, false 不删除 

            popFolder.close(true); 

            // 8. 关闭 store, 断开网络连接 

            store.close(); 

        } catch (NoSuchProviderException e) { 

            // TODO Auto-generated catch block 

            e.printStackTrace(); 

        } catch (Exception e) { 

            // TODO Auto-generated catch block 

            e.printStackTrace(); 

        } 

    }

    /** 

     * @param args 

     */ 

    public static void main(String[] args) { 

        new POP3MailReceiverTest();

    }

}

java邮件解析的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java邮件附件解析、java邮件解析的信息别忘了在本站进行查找喔。