You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by "SHAW, Thomas" <SH...@aisl.uk.com> on 2009/07/10 09:55:35 UTC

Sending HTML emails in Geronimo

> Hi Guys,
> 
> I am having problems sending html emails from a geronimo server. When my code runs on the J2EE preview server in eclipse everything works fine. Is there anything i need to configure on the server to assist the sending of these emails?
> 
> The email arrives in my inbox as text format not html
> 
> Can anybody explain what i am doing wrong?
> 
> Here is a clip of the code:
> 
> 		Message msg = new MimeMessage(session);
> 			
> 		msg.setFrom(new InternetAddress(from));
> 		msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(
> 					to, false));	
> 		msg.setSubject(subject);
> 		msg.setContent(body, "text/html");
> 		
> 		//StringBuffer sbuf = new StringBuffer(body);
> 		//msg.setContent(new String(sbuf.toString().getBytes(), "iso-8859-1"), "text/html; charset=\"iso-8859-1\"");
> 		//msg.setHeader("Content-Transfer-Encoding", "7bit");
> 		
> 		msg.setSentDate(new Date());
> 		Transport.send(msg);
> 
> 
> This is the content of the email when it arrives as text:
> 
> MIME-Version: 1.0
> Content-Type: text/html; charset=iso-8859-1
> Content-Transfer-Encoding: quoted-printable
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><=
> meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DISO-8859-1"=
>  /><title>GEQ004A_quote_1207.html</title></head><body><%@ include view=3D"gl=
> adiator_mirror_page_left" %><table width=3D"600" border=3D"0" cellspacing=3D=
> "0" cellpadding=3D"0">  <tr>    <td width=3D"200" height=3D"10" bgcolor=3D"#=
> 009933"></td>    <td width=3D"350" bgcolor=3D"#009933"></td>    <td width=3D=
> "50" bgcolor=3D"#009933"></td>  </tr>  <tr>    <td valign=3D"top"><table wid=
> th=3D"200" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">      <tr>      =
>   <td><a href=3D"http://www.gladiator.co.uk/?media=3Dqfuem"><img src=3D"http=
> ://localhost/GladQE/pages/gladiator/emails/GEQ004A/gc_home_pic_top_0806.jpg"=
> 
> Thanks for your time
> 
> Tom

****** This email is sent for and on behalf of  Admiral Group plc ******

Admiral Group plc is registered in England and Wales at Capital Tower, Greyfriars Road, Cardiff CF10 3AZ (Reg. No. 03849958). EUI Limited (Reg No: 02686904) is a subsidiary of Admiral Group plc and is authorised and regulated by the Financial Services Authority (Firm reference number: 309378). These details can be confirmed by visiting the Financial Services Authority's Register, www.fsa.gov.uk/register. EUI Limited acts for, and on behalf of, other regulated insurance companies. Further details may be provided on request.

Any opinions expressed in this email are those of the individual and not necessarily the company. This email and any files transmitted with it, including replies and forwarded copies (which may contain alterations) subsequently transmitted from the Company, are confidential and solely for the use of the intended recipient. It may contain material protected by attorney-client privilege. If you are not the intended recipient or the person responsible for delivering to the intended recipient, be advised that you have received this email in error and that any use is strictly prohibited.

If you have received this email in error please notify the Information Security Officer by telephone on +44 (0) 29 2043 4252. Please then delete this email and destroy any copies of it.
Security Warning: Please note that this email has been created in the knowledge that Internet email is not a 100% secure communications medium.  We advise that you understand and accept this lack of security when emailing us.
Viruses: Although we have taken steps to ensure that this email and any attachments are free from any virus, we advise that in keeping with good computing practice the recipient should ensure they are actually virus free.
We may monitor the content of emails sent and received via our network for viruses or unauthorised use and for other lawful business purposes.

________________________________________________________________________
This e-mail has been scanned for all viruses by Messagelabs. The
service is powered by MessageLabs. ________________________________________________________________________

RE: Sending HTML emails in Geronimo

Posted by "SHAW, Thomas" <SH...@aisl.uk.com>.
Thanks Rick i will check this out now!

-----Original Message-----
From: Rick McGuire [mailto:rickmcg@gmail.com]
Sent: 10 July 2009 10:53
To: user@geronimo.apache.org
Subject: Re: Sending HTML emails in Geronimo


To send HTML mail, you need to use a multipart body.  Here's a very nice 
article on how to do this:

http://java.sun.com/developer/EJTechTips/2004/tt0426.html

Rick

SHAW, Thomas wrote:
>
> Hi Guys,
>
> I am having problems sending html emails from a geronimo server. When 
> my code runs on the J2EE preview server in eclipse everything works 
> fine. Is there anything i need to configure on the server to assist 
> the sending of these emails?
>
> The email arrives in my inbox as text format not html
>
> Can anybody explain what i am doing wrong?
>
> Here is a clip of the code:
>
>                 Message_ msg_ = new MimeMessage(session);
>                        
>                _ msg_.setFrom(new InternetAddress(from));
>                _ msg_.setRecipients(Message.RecipientType.TO, 
> InternetAddress.parse(
>                                         to, false));   
>                _ msg_.setSubject(subject);
>                _ msg_.setContent(body, "text/_html_");
>                
>                 //StringBuffer_ sbuf_ = new StringBuffer(body);
>                 //_msg_.setContent(new 
> String(_sbuf_.toString().getBytes(), "_iso_-8859-1"), "text/_html_;_ 
> charset_=\"_iso_-8859-1\"");
>
>                 //_msg_.setHeader("Content-Transfer-Encoding", "7bit");
>                
>                 msg.setSentDate(new Date());
>                 Transport.send(_msg_);
>
>
> This is the content of the email when it arrives as text:
>
> MIME-Version: 1.0
> Content-Type: text/html; charset=iso-8859-1
> Content-Transfer-Encoding: quoted-printable
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 
> Transitional//EN"><html><head><=
> meta http-equiv=3D"Content-Type" content=3D"text/html; 
> charset=3DISO-8859-1"=
>  /><title>GEQ004A_quote_1207.html</title></head><body><%@ include 
> view=3D"gl=
> adiator_mirror_page_left" %><table width=3D"600" border=3D"0" 
> cellspacing=3D=
> "0" cellpadding=3D"0">  <tr>    <td width=3D"200" height=3D"10" 
> bgcolor=3D"#=
> 009933"></td>    <td width=3D"350" bgcolor=3D"#009933"></td>    <td 
> width=3D=
> "50" bgcolor=3D"#009933"></td>  </tr>  <tr>    <td 
> valign=3D"top"><table wid=
> th=3D"200" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">      
> <tr>      =
>   <td><a href=3D"http://www.gladiator.co.uk/?media=3Dqfuem"><img 
> src=3D"http=
> ://localhost/GladQE/pages/gladiator/emails/GEQ004A/gc_home_pic_top_0806.jpg"= 
>
>
> Thanks for your time
>
> Tom
>
> ****** This email is sent for and on behalf of Admiral Group plc ******
>
>  
>
> Admiral Group plc is registered in England and Wales at Capital Tower, 
> Greyfriars Road, Cardiff CF10 3AZ (Reg. No. 03849958). EUI Limited 
> (Reg No: 02686904) is a subsidiary of Admiral Group plc and is 
> authorised and regulated by the Financial Services Authority (Firm 
> reference number: 309378). These details can be confirmed by visiting 
> the Financial Services Authority's Register, www.fsa.gov.uk/register. 
> EUI Limited acts for, and on behalf of, other regulated insurance 
> companies. Further details may be provided on request.
>
>  
>
> Any opinions expressed in this email are those of the individual and 
> not necessarily the company. This email and any files transmitted with 
> it, including replies and forwarded copies (which may contain 
> alterations) subsequently transmitted from the Company, are 
> confidential and solely for the use of the intended recipient. It may 
> contain material protected by attorney-client privilege. If you are 
> not the intended recipient or the person responsible for delivering to 
> the intended recipient, be advised that you have received this email 
> in error and that any use is strictly prohibited.
>
>  
>
> If you have received this email in error please notify the Information 
> Security Officer by telephone on +44 (0) 29 2043 4252. Please then 
> delete this email and destroy any copies of it.
>
> Security Warning: Please note that this email has been created in the 
> knowledge that Internet email is not a 100% secure communications 
> medium. We advise that you understand and accept this lack of security 
> when emailing us.
>
> Viruses: Although we have taken steps to ensure that this email and 
> any attachments are free from any virus, we advise that in keeping 
> with good computing practice the recipient should ensure they are 
> actually virus free.
>
> We may monitor the content of emails sent and received via our network 
> for viruses or unauthorised use and for other lawful business purposes.
>
>
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Messagelabs. The
> service is powered by MessageLabs. 
> ________________________________________________________________________


_____________________________________________________________________
This message has been checked for all known viruses by bluesource. For further information visit www.blue-source.com  

powered by Messagelabs

________________________________________________________________________
This e-mail has been scanned for all viruses by Messagelabs. The
service is powered by MessageLabs. ________________________________________________________________________

Re: Sending HTML emails in Geronimo

Posted by Rick McGuire <ri...@gmail.com>.
To send HTML mail, you need to use a multipart body.  Here's a very nice 
article on how to do this:

http://java.sun.com/developer/EJTechTips/2004/tt0426.html

Rick

SHAW, Thomas wrote:
>
> Hi Guys,
>
> I am having problems sending html emails from a geronimo server. When 
> my code runs on the J2EE preview server in eclipse everything works 
> fine. Is there anything i need to configure on the server to assist 
> the sending of these emails?
>
> The email arrives in my inbox as text format not html
>
> Can anybody explain what i am doing wrong?
>
> Here is a clip of the code:
>
>                 Message_ msg_ = new MimeMessage(session);
>                        
>                _ msg_.setFrom(new InternetAddress(from));
>                _ msg_.setRecipients(Message.RecipientType.TO, 
> InternetAddress.parse(
>                                         to, false));   
>                _ msg_.setSubject(subject);
>                _ msg_.setContent(body, "text/_html_");
>                
>                 //StringBuffer_ sbuf_ = new StringBuffer(body);
>                 //_msg_.setContent(new 
> String(_sbuf_.toString().getBytes(), "_iso_-8859-1"), "text/_html_;_ 
> charset_=\"_iso_-8859-1\"");
>
>                 //_msg_.setHeader("Content-Transfer-Encoding", "7bit");
>                
>                 msg.setSentDate(new Date());
>                 Transport.send(_msg_);
>
>
> This is the content of the email when it arrives as text:
>
> MIME-Version: 1.0
> Content-Type: text/html; charset=iso-8859-1
> Content-Transfer-Encoding: quoted-printable
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 
> Transitional//EN"><html><head><=
> meta http-equiv=3D"Content-Type" content=3D"text/html; 
> charset=3DISO-8859-1"=
>  /><title>GEQ004A_quote_1207.html</title></head><body><%@ include 
> view=3D"gl=
> adiator_mirror_page_left" %><table width=3D"600" border=3D"0" 
> cellspacing=3D=
> "0" cellpadding=3D"0">  <tr>    <td width=3D"200" height=3D"10" 
> bgcolor=3D"#=
> 009933"></td>    <td width=3D"350" bgcolor=3D"#009933"></td>    <td 
> width=3D=
> "50" bgcolor=3D"#009933"></td>  </tr>  <tr>    <td 
> valign=3D"top"><table wid=
> th=3D"200" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">      
> <tr>      =
>   <td><a href=3D"http://www.gladiator.co.uk/?media=3Dqfuem"><img 
> src=3D"http=
> ://localhost/GladQE/pages/gladiator/emails/GEQ004A/gc_home_pic_top_0806.jpg"= 
>
>
> Thanks for your time
>
> Tom
>
> ****** This email is sent for and on behalf of Admiral Group plc ******
>
>  
>
> Admiral Group plc is registered in England and Wales at Capital Tower, 
> Greyfriars Road, Cardiff CF10 3AZ (Reg. No. 03849958). EUI Limited 
> (Reg No: 02686904) is a subsidiary of Admiral Group plc and is 
> authorised and regulated by the Financial Services Authority (Firm 
> reference number: 309378). These details can be confirmed by visiting 
> the Financial Services Authority's Register, www.fsa.gov.uk/register. 
> EUI Limited acts for, and on behalf of, other regulated insurance 
> companies. Further details may be provided on request.
>
>  
>
> Any opinions expressed in this email are those of the individual and 
> not necessarily the company. This email and any files transmitted with 
> it, including replies and forwarded copies (which may contain 
> alterations) subsequently transmitted from the Company, are 
> confidential and solely for the use of the intended recipient. It may 
> contain material protected by attorney-client privilege. If you are 
> not the intended recipient or the person responsible for delivering to 
> the intended recipient, be advised that you have received this email 
> in error and that any use is strictly prohibited.
>
>  
>
> If you have received this email in error please notify the Information 
> Security Officer by telephone on +44 (0) 29 2043 4252. Please then 
> delete this email and destroy any copies of it.
>
> Security Warning: Please note that this email has been created in the 
> knowledge that Internet email is not a 100% secure communications 
> medium. We advise that you understand and accept this lack of security 
> when emailing us.
>
> Viruses: Although we have taken steps to ensure that this email and 
> any attachments are free from any virus, we advise that in keeping 
> with good computing practice the recipient should ensure they are 
> actually virus free.
>
> We may monitor the content of emails sent and received via our network 
> for viruses or unauthorised use and for other lawful business purposes.
>
>
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Messagelabs. The
> service is powered by MessageLabs. 
> ________________________________________________________________________