Javamail, get message body
I have the following problem: my email client, using Javamail, can get all the parts of the emails just like sentdate, su开发者_运维问答bject, from, to etc., but I cannot figure it out how to get the body of the message.
I already tried getContent() function but it does not give me the required texts.
Any help will be great.
Thanks, Hectai
It would help if you could post your code.
I don't know if this is what you are expecting, but "getContent()" doesn't necessarily return a String with the message in it.
Look at the JavaDocs here - it returns an Object.
This might be a String, or a Multipart, or it might be an InputStream. It all depends upon the email message.
I'd suggest trying to print out the type of the Object that getContent() is returning.
Also, please have a read through the docs.
You find a comprehensive introduction how to use the API here Fundamentals of the JavaMail API which provides many examples as code snippets.
精彩评论