Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
909 views
in Programming by
recategorized by

I am reading email via IMAP.

I am getting follwing output when I call "message.getContent().toString()"

 

javax.mail.internet.MimeMultipart@451cf8e9

How do I resolve this?

1 Answer

0 like 0 dislike
by
 
Best answer

I am using this function and its working like charm

 

public static String bodyFromMimeType(Object message) throws MessagingException, IOException{
String body = message.toString();
if(message instanceof Multipart){
Multipart multipart = (Multipart) message;
for(int x = 0; x < multipart.getCount() ; x++){
BodyPart bodyPart = multipart.getBodyPart(x);
String disposition = bodyPart.getDisposition();
if(disposition !=null && disposition.equals(BodyPart.ATTACHMENT))
continue;
else{
return
bodyPart.getContent().toString();
}
 
}
}
return body;
}


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

...