Hi guys!
I needed to send HTML formatted mail, so I patched the MailModule a little. If anybody
else needs this, here is one way to do it.
It checks if the first character in the body is a "<". If it is, it assumes this is
html, otherwise it's text. A little crude, but it works.
In the MailModule in the method deliver (int, String, String, String, String, String),
replace the following code
| // Prepare message
| MimeMessage message = new MimeMessage(session);
| message.setFrom(new InternetAddress(from));
| message.setSubject(subject);
| message.setText(body);
| message.setSentDate(new Date());
| message.addRecipient(javax.mail.Message.RecipientType.TO, toAddress);
|
with this:
| // Prepare message
| MimeMessage message = new MimeMessage(session);
| message.setFrom(new InternetAddress(from));
| message.setSubject(subject);
| message.setSentDate(new Date());
| message.addRecipient(javax.mail.Message.RecipientType.TO, toAddress);
|
| if (body != null && body.length() > 0 && body.substring(0, 1).equals("<")) {
| // Assume HTML
| BodyPart messageBodyPart = new MimeBodyPart();
| messageBodyPart.setContent(body, "text/html");
| MimeMultipart multipart = new MimeMultipart("related");
| multipart.addBodyPart(messageBodyPart);
| message.setContent(multipart);
| } else {
| // Default = text
| message.setText(body);
| }
|
You will also need to add these extra imports:
| import javax.mail.BodyPart;
| import javax.mail.internet.MimeBodyPart;
| import javax.mail.internet.MimeMultipart;
|
Good luck.
brgds Per-Erik
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3823624#3823624
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3823624
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development