wood burning stoves
The moose likes Other JSE/JEE APIs and the fly likes Mail body coming with HTML tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Mail body coming with HTML tags" Watch "Mail body coming with HTML tags" New topic

Mail body coming with HTML tags

SoumyaGh Ghosh

Joined: Mar 02, 2013
Posts: 6

I have a scenario of using java mail api as below:
I am reading Outlook/exchange server using java mail IMAP. The message bodies (including the cases which are of content type text/html) I am saving in local DB. But those contents are coming within <html> tags with all it's styles etc. These are nothing but the view source content of the mail bodies of outlook mails. I have to create one window for showing, replying the mails from my own application. So when I am showing those mail bodies within a text area from my jsp page, contents are showing with <html> tags, for that it's not possible to read the exact mail body contents. Also as there are features to reply or forward those mails, for that I need to provide text area support so that user can type further contents. Can anyone please suggest any idea how can I show only the mail bodies without html tags. Is there any option to provide html support for textarea contents? or I have to set specific content type at the type of mail reading from exchange server?
Pankaj Kr. Singh
Ranch Hand

Joined: Mar 31, 2011
Posts: 32

Hi SoumyaGh,

Use the MimeBodyPart and use the Input stream and read the message and save where ever you need to save

For example

I agree. Here's the link: http://aspose.com/file-tools
subject: Mail body coming with HTML tags
It's not a secret anymore!