aspose file tools*
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
Author

use javamail to send html email

Lichun Ji
Greenhorn

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);
out.write(sb.toString().getBytes());
FileDataSource fds = new FileDataSource(file);
mbp.setDataHandler(new DataHandler(fds));
msg.setContent(mbp);
The sent email is plain text instead of html format and looks like:
--18658963.1028124230568.JavaMail.SYSTEM.tis
<HTML>
<HEAD>
<TITLE>Test</TITLE>
</HEAD>
<BODY>
...
</BODY>
</HTML>
--18658963.1028124230568.JavaMail.SYSTEM.tis--
Can anyone help me? Any advise is very welcomed. Thanks.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
jill,
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.
Thanks,
Cindy


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

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: http://aspose.com/file-tools
 
subject: use javamail to send html email