Holger's
Java API

com.antelmann.net.mail
Class SQLEmailCustomizer

java.lang.Object
  extended by com.antelmann.net.mail.SQLEmailCustomizer
All Implemented Interfaces:
EmailCustomizer, Closeable

public class SQLEmailCustomizer
extends Object
implements EmailCustomizer, Closeable

uses a JDBC connection to customize emails. All existing occurrences of ${columnName} will be replaced with the value stored in the column of the row where the email address equals the address of the InternetAddress object that is to be used.

Author:
Holger Antelmann

Constructor Summary
SQLEmailCustomizer(Connection con, String tableName, String emailColumn)
           
 
Method Summary
 void close()
          does not close the embedded connection
protected  void customizeReplacement(Email email, javax.mail.internet.InternetAddress address, Map<String,Object> params)
          used to customize the replacement.
protected  void finalize()
           
 String[] getAddresses()
           
 javax.mail.internet.InternetAddress[] getInternetAddresses()
           
 void individualizeEmail(Email email, javax.mail.internet.InternetAddress address)
          this method is called by the EmailAccount.send() method to individualize the body of an email given the address.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLEmailCustomizer

public SQLEmailCustomizer(Connection con,
                          String tableName,
                          String emailColumn)
                   throws SQLException
Throws:
SQLException
Method Detail

individualizeEmail

public void individualizeEmail(Email email,
                               javax.mail.internet.InternetAddress address)
                        throws javax.mail.MessagingException
Description copied from interface: EmailCustomizer
this method is called by the EmailAccount.send() method to individualize the body of an email given the address.

Specified by:
individualizeEmail in interface EmailCustomizer
Throws:
javax.mail.MessagingException
See Also:
EmailAccount.sendEmails(Email, InternetAddress[], EmailCustomizer, Monitor)

customizeReplacement

protected void customizeReplacement(Email email,
                                    javax.mail.internet.InternetAddress address,
                                    Map<String,Object> params)
used to customize the replacement. This implementation follows this rule: All existing occurrences of ${key} will be replaced with the value retrieved from the props parameter. The props map will be filled with the row data for the given address, with the column name as the key and the cell data as value. If more sophisticated decision-making is required to construct the email message, this method can simply be overwritten.


getAddresses

public String[] getAddresses()
                      throws SQLException
Throws:
SQLException

getInternetAddresses

public javax.mail.internet.InternetAddress[] getInternetAddresses()
                                                           throws SQLException,
                                                                  javax.mail.internet.AddressException
Throws:
SQLException
javax.mail.internet.AddressException

close

public void close()
           throws IOException
does not close the embedded connection

Specified by:
close in interface Closeable
Throws:
IOException

finalize

protected void finalize()
                 throws SQLException
Overrides:
finalize in class Object
Throws:
SQLException


(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads