I am able to connect to the pop server and check for all the new emails, get the subject of the email, time of the email. But when I am trying to read the content of the email it is not working,it is giving an exception.
Can any one guide me in this regard how to retrive the content of the email body.
snap of code:
for(int i = 1; i <=msgCount; i++) {
Message m1 = folder.getMessage(i);
// Get some headers
Date date = m1.getSentDate();
Address [] from = m1.getFrom();
String subj = m1.getSubject();
String mimeType = m1.getContentType();
out.println("This is the mail oon "+date + "\t" + from[0] +"of vk"+subj );
//read the data
Object o = m1.getContent();
if (o instanceof String) {
out.println("**This is a String Message**");
out.println((String)o);
}
Start Free Trial