in project required read mails , save content in hard drive, ms exchange email box using javamail. found simplest email receive saved html content, head body , on, when write 2 words format, without images, no attachment. want text of email.
part of code:
object content = part.getcontent(); if (content instanceof inputstream || content instanceof string) { if (part.attachment.equalsignorecase(part.getdisposition()) || stringutils.isnotblank(part.getfilename())) { string messagebody = part.getcontent().tostring(); ....(write string files) } } i may write:
hello world. and txt html code, , fontface , tags <html> , on.
i saw this question , found him retrieving text content cannot comment there, must post new question, , see no difference between code , his. wrote:
if (disposition != null && (disposition.equals(bodypart.attachment))) { datahandler handler = bodypart.getdatahandler(); s1 = (string) bodypart.getcontent();` so datahandler? not used anywhere? can help?
first of all, you'll want read javamail faq entry tells how find main message body. written, prefers html body on plain text body in cases message contains both. should clear how reverse preference.
but, not messages contain both html , plain text versions of message body. if html, you're going have write own code process string , remove html tags, or use other product process html , remove tags.
Comments
Post a Comment