You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know if this is an issue of the project or the email server provider, but there is a problem on converting MimeMessage to Email.
I try to use https://ethereal.email to test emails. I use this code to fetch and get the emails via IMAP:
public static void main(String[] args) {
Properties props = new Properties();
props.setProperty("mail.store.protocol", "imaps");
props.setProperty("mail.debug", "true");
Folder inbox = null;
Store store = null;
try {
// Connect to the server
System.out.println("Connect to the server");
Session session = Session.getInstance(props);
String host = "imap.ethereal.email";
String username = "qvvaodrw3lvfxboy@ethereal.email";
String password = "4qvcgpNsPhwnQDNgzE";
String provider = "imaps";
store = session.getStore(provider);
store.connect(host, username, password);
// open the inbox folder
System.out.println("open the inbox folder");
inbox = store.getFolder("INBOX");
UIDFolder uf = (UIDFolder) inbox;
inbox.open(Folder.READ_ONLY);
SearchTerm term = new SearchTerm() {
private static final long serialVersionUID = 1L;
public boolean match(Message message) {
Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_MONTH, -1);
Date when = c.getTime();
try {
if (message.getReceivedDate().after(when)) {
return true;
}
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
};
Message[] searchMessages = inbox.search(term);
for (Message msg : searchMessages) {
long uid = uf.getUID(msg);
System.out.println("uid: " + uid);
MimeMessage mimeMsg = (MimeMessage) msg;
Email email = EmailConverter.mimeMessageToEmail(mimeMsg);
String html = email.getTextHTML();
String text = html.substring(0, html.indexOf(DELIMITER));
System.out.println(text);
}
}
catch (Exception ex) {
System.out.println("Thread has a problem...");
ex.printStackTrace();
}
finally {
// close the inbox folder but do not
// remove the messages from the server
try {
inbox.close(false);
} catch (MessagingException e) {
e.printStackTrace();
}
try {
store.close();
} catch (MessagingException e) {
e.printStackTrace();
}
System.out.println("Thread is closing...");
}
}
I got this exception:
java.lang.IllegalArgumentException: value is required
at org.simplejavamail.internal.util.Preconditions.checkNonEmptyArgument(Preconditions.java:15)
at org.simplejavamail.email.Email.addHeader(Email.java:519)
at org.simplejavamail.converter.EmailConverter.fillEmailFromMimeMessage(EmailConverter.java:245)
at org.simplejavamail.converter.EmailConverter.mimeMessageToEmail(EmailConverter.java:56)
I debugged the code and I got that the key of the header is: X-MS-TNEF-Correlator
The value is an empty string.
At this point, only because of a missing header value, I cannot get the email message converted. Isn't it some weird? I can get the other parts of the email by using all the other methods. But here, I think simple-mail should let me have the rest of the email converted even if there are some missing header parts (which I don't even know if we need or not).
The text was updated successfully, but these errors were encountered:
I don't know if this is an issue of the project or the email server provider, but there is a problem on converting MimeMessage to Email.
I try to use https://ethereal.email to test emails. I use this code to fetch and get the emails via IMAP:
I got this exception:
I debugged the code and I got that the key of the header is: X-MS-TNEF-Correlator
The value is an empty string.
At this point, only because of a missing header value, I cannot get the email message converted. Isn't it some weird? I can get the other parts of the email by using all the other methods. But here, I think simple-mail should let me have the rest of the email converted even if there are some missing header parts (which I don't even know if we need or not).
The text was updated successfully, but these errors were encountered: