Skip to content
Advertisement

How to read text inside body of mail using javax.mail

i’m developing a client mail using javax.mail to read mail inside mail box:

JavaScript

I know that the method getContent() returns an object cause the content could be a String, a MimeMultiPart, a SharedByteArrayInputstream and other ( i think )… Is there a way to get always the text inside body of message? Thanks!!

Advertisement

Answer

This answer extends yurin’s answer. The issue he brought up was that the content of a MimeMultipart may itself be another MimeMultipart. The getTextFromMimeMultipart() method below recurses in such cases on the content until the message body has been fully parsed.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement