File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

use javamail to send html email

 
Lichun Ji
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that you have the JavaMail API and the Java Activation Framework, you can read this article on Basic HTML Sending.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic