0
https://i.stack.imgur.com/MnfDs.png
在上述圖中,我們提到輸入文件,這給輸入在EML的形式時獲得空。
MimeMessageParser mmparser = new MimeMessageParser(message);
mmparser.parse();
System.out.println("Subject1: " + mmparser.getSubject());
List<DataSource> attachmentList = mmparser.getAttachmentList();
System.out.println("Number of attachment " + attachmentList.size());
DataSource ds1 = mmparser.getAttachmentList().get(0);
System.out.println("Content Type:" + ds1.getContentType());
final Session mail_session = Session.getDefaultInstance(new java.util.Properties());
final MimeMessage mimeMsgAtt = new MimeMessage(mail_session, ds1.getInputStream());
MimeMessageParser mmparserAttachment = new MimeMessageParser(mimeMsgAtt);
MimeMessageParser mmparser1 = new MimeMessageParser(mmparserAttachment.getMimeMessage());
mmparser1.parse();
System.out.println("Subject2: " + mmparser1.getSubject());
List<DataSource> attachNum = mmparser1.getAttachmentList();
System.out.println("Number of attachment:" +attachNum.size());
DataSource dsX2 = mmparser1.getAttachmentList().get(0);
final MimeMessage mimeMsgAttX1 = new MimeMessage(mail_session, dsX2.getInputStream());
MimeMessageParser mmparserAttachmentX2 = new MimeMessageParser(mimeMsgAttX1);
MimeMessageParser mmparser2 = new MimeMessageParser(mmparserAttachmentX2.getMimeMessage());
mmparser2.parse();
// THE PROBLEM, subject is null
System.out.println("Subject3: " + mmparser2.getSubject());
> output
:Subject1: Undeliverable: GEET - Downtime Notification for E411
Number of attachment 1
Content Type: message/rfc822
Subject2: Undeliverable: GEET - Downtime Notification for E411
Number of attachment: 2
Subject3: null
在這裏我們不能訪問第三個主題是GEET - 爲E411停機通知。我無法找到我犯錯的地方,請幫助我。
先生,我得到的第三來自msgshow.java。但我沒有通過MimeMessageParser訪問。我還在eml文件中更改了「CONTENT-TYPE:text/plain; charset = us-ascii」。我想通過MimeMessageParser得到結果。 – Ashish
對不起,我幫不了你。這不是JavaMail的一部分,我對此一無所知。 –