I'm using javamail to rescue mails of inbox. I get all mails from inbox, but the subject(message.getSubject()) return null.
I research in several sites and all proposed solutions not work.
This problem occurs only in the Tomcat6, if a execute even code in java project for main method i get all atributis, include subject. I'm user de SSL protocol (pop3s).
Thanks for help
public void getMails(final String host, final int port, final String user, final String password){
final Session session = Session.getInstance(System.getProperties(), null);
final Store store = session.getStore("pop3s");
store.connect(host, port, user, password);
Folder inbox = store.getFolder("INBOX");
inbox.open(Folder.READ_WRITE);
int count = inbox.getMessageCount();
System.out.println(" Count Emails "+count);
final Message[] messages = inbox.getMessages();
for (final Message message : messages) {
//This return null
System.out.print("mail subject: " + message.getSubject() + " send at: " + message.getSentDate());
//This return body of mail
System.out.print("mail subject: " + message.getContent().toString());
}
My output for the method Main directly on eclipse:
MessageCount: 4
full name: INBOX
NewMessageCount: 0
getDescription: null
getFileName: null
getMessageNumber: 1
getSize: 2297
getSentDate: Mon Aug 03 17:23:10 BRT 2015
from: Silvano Wojczak silvano.wojczak@softexpertjlle.onmicrosoft.com
Content: javax.mail.internet.MimeMultipart@6769ba97
Content getClass: class javax.mail.internet.MimeMultipart
For log4j in TomCat6:
MessageCount: 4
full name: INBOX
NewMessageCount: 0
getDescription: null
getFileName: null
getMessageNumber: 1
getSize: 6731
getSentDate: null
from: null
Content: javax.mail.internet.MimeMultipart@6769ba97
Content getClass: class javax.mail.internet.MimeMultipart
Aucun commentaire:
Enregistrer un commentaire