Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

0
how do i extract mime type email from email body

Solved 1 Answers 744 Views Programming
0 1

I am reading email via IMAP.

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

 

[email protected]

How do I resolve this?

1 Answer

0
Best answer
0

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;
}
answered by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
...