Hi to all,
I have wrote code to read mail from Gmail.I have read the mail content using Mime message.At that time i face one difficulty that is i can't read the exact content from Mail.The mail content contains the html contents also.How can i get the exact content from mail.Code for read the content is
public void getContent()
Multipart mp = (Multipart) msg.getContent();
int count = mp.getCount();
for (int i = 0; i < count; i++)
public void dumpPart(Part p) throws Exception
InputStream is = p.getInputStream();
if (!(is instanceof BufferedInputStream))
is = new BufferedInputStream(is);
System.out.println("Message : ");
while ((c = is.read()) != -1)
please try to solve my problem.Thanks in advance.
Not sure what you mean by "the exact content" - are you saying that the code returns something other than what's in the mail? That would sound like a bug.
Or are you saying that it returns HTML when you actually want just the plain text? If so, you can use a library like TagSoup to access the text components of the HTML. That's outside the scope of JavaMail.
Joined: Mar 19, 2010
Thanks for your reply.You are correct i actually want just the plain text.But it contents html tags also.you said to use tagsoup for get html content only.I will try to do it.