FileDocCategorySizeDatePackage
MailUtil.javaAPI DocJBoss 4.2.11581Fri Jul 13 20:55:36 BST 2007xpetstore.util

MailUtil

public class MailUtil extends Object
author
Herve Tchepannou

Fields Summary
public static final String
MAIL_SESSION
Constructors Summary
Methods Summary
public static voidsend(java.lang.String to, java.lang.String subject, java.lang.String body)


    //~ Methods ----------------------------------------------------------------

         
                              
                               
          
                    
                   
    
        InitialContext     ic = new InitialContext(  );
        Session            session = ( Session ) ic.lookup( MAIL_SESSION );
        javax.mail.Message msg = new MimeMessage( session );

        msg.setFrom(  );
        msg.setRecipients( javax.mail.Message.RecipientType.TO, InternetAddress.parse( to, false ) );
        msg.setSubject( subject );

        msg.setDataHandler( new DataHandler( body, "text/plain" ) );
        msg.setHeader( "X-Mailer", "JavaMailer" );
        msg.setSentDate( new Date(  ) );

        Transport.send( msg );