File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes use javamail to send html email Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "use javamail to send html email" Watch "use javamail to send html email" New topic

use javamail to send html email

Lichun Ji

Joined: Jul 31, 2002
Posts: 1
Hi, I 've tried several methods to send html format mail to the viewer Novell GroupWise but failed.
The methods I have tried:
1. use setConent of MimeMessage and set the message type to text/html
2. create bodypart and add the content:
Sb -- StringBuffer
msg.setDataHandler(new DataHandler(
new ByteArrayDataSource(sb.toString(), "text/html")));
3. send the html content as attached file
MimeBodyPart mbp = new MimeBodyPart();
File file = new File("Mime.822");
FileOutputStream out = new FileOutputStream(file);
FileDataSource fds = new FileDataSource(file);
mbp.setDataHandler(new DataHandler(fds));
The sent email is plain text instead of html format and looks like:
Can anyone help me? Any advise is very welcomed. Thanks.
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Please change your name to be compliant with JavaRanch's naming policy.
Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name.

"JavaRanch, where the deer and the Certified play" - David O'Meara
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Assuming that you have the JavaMail API and the Java Activation Framework, you can read this article on Basic HTML Sending.
I agree. Here's the link:
subject: use javamail to send html email
It's not a secret anymore!