When i am trying to retrieve gmail content through getcontent()
method i am getting following exception
java.lang.ClassCastException: com.sun.mail.imap.IMAPInpustream cannot be cast to javax.mail.Multipart
So I converted the inputsream to string but it ios reurning all the data including which is not text/html. But i want only text/html data with attachment if any.
My code:
if(contentType.contains("multipart/alternative") || contentType.contains("multipart/MIXED")){
Log.i("content type...","inside if stmt "+contentType);
Multipart mp = (Multipart)gmsg.getGmailContent();
try {
for(int k=0;k<mp.getCount();k++){
javax.mail.BodyPart p = mp.getBodyPart(k);
if("text/html".equals(p.getContentType())){
/* gContent.loadDataWithBaseURL("https://mail.google.com",
p.getContent().toString() , "text/plain","UTF-8", null); */
Log.i("msg", p.getContent().toString());
}
}
} catch (MessagingException e) {
// TODO Auto-generated catch block
Log.i("error", e.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
I have included mail.jar,activation.jar,additional.jar in libs folder.
Searched in google a lot but didn't get any solution. Plz help..Thanks in advance..