Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

javamail api reading email message body problem  RSS feed

 
Ben Zaidi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I have a requirement to read the email from a server, extract the email headers, and body of the message.
I have extracted headers and have read the body as well, by writing this piece of code.

Part p;
InputStream io = p.getInputStream();

for(int i= 0;i < io.available(); i++)
{
System.out.print((char)io.read());
}

Well, problem is that, it reads the body of message, but it reads all HTML tags as well. Like for example, if my body message has

hi, how are you

It will be read it as

<div dir="ltr">hello

--
Michael Thoma
Senior Software Enginner

Though i want simply
Hello.Michael Thomas

Is there something i am doing wrong, can i achieve the above result somewhow?

 
Rob Spoor
Sheriff
Posts: 21090
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the email is sent as HTML email (with or without attachments) without a plain text part, then you have to strip out those tags yourself. Do a search and you will find enough examples.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!