gov.nih.nci.caarray.util
Class EmailUtil

java.lang.Object
  extended by gov.nih.nci.caarray.util.EmailUtil

public final class EmailUtil
extends java.lang.Object

Utility class that sends emails. Email configuration is retrieved from the application server settings using a JNDI lookup.

Author:
John Hedden (Amentra, Inc.), Akhil Bhaskar (Amentra, Inc.)

Method Summary
 javax.mail.Session getMailSession()
          Returns a handle on the populated mail session object.
static void sendMail(java.util.List<java.lang.String> mailRecipients, java.lang.String from, java.lang.String mailSubject, java.lang.String mailBody)
          Sends mail based upon input parameters.
static void sendMultipartMail(java.util.List<java.lang.String> mailRecipients, java.lang.String from, java.lang.String mailSubject, java.lang.String htmlMailBody, java.lang.String plainMailBody)
          Sends a multipart email with both HTML and plain-text bodies based upon input parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getMailSession

public javax.mail.Session getMailSession()
Returns a handle on the populated mail session object.

Returns:
the populate mail session object.

sendMail

public static void sendMail(java.util.List<java.lang.String> mailRecipients,
                            java.lang.String from,
                            java.lang.String mailSubject,
                            java.lang.String mailBody)
                     throws javax.mail.MessagingException
Sends mail based upon input parameters.

Parameters:
mailRecipients - List of strings that are the recipient email addresses
from - the from of the email
mailSubject - the subject of the email
mailBody - the body of the email
Throws:
javax.mail.MessagingException - thrown if there is a problem sending the message

sendMultipartMail

public static void sendMultipartMail(java.util.List<java.lang.String> mailRecipients,
                                     java.lang.String from,
                                     java.lang.String mailSubject,
                                     java.lang.String htmlMailBody,
                                     java.lang.String plainMailBody)
                              throws javax.mail.MessagingException
Sends a multipart email with both HTML and plain-text bodies based upon input parameters.

Parameters:
mailRecipients - List of strings that are the recipient email addresses
from - the from of the email
mailSubject - the subject of the email
htmlMailBody - the HTML version of the body of the email
plainMailBody - the plain-text version of the body of the email
Throws:
javax.mail.MessagingException - thrown if there is a problem sending the message