Holger's Java API

## com.antelmann.net.mail
Class SQLEmailCustomizer

    java.lang.Object
      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()`
`boolean` `individualizeEmail(Email email, javax.mail.internet.InternetAddress address)` this method is called by the `EmailAccount.send()` method to individualize this particular email for 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 boolean individualizeEmail(Email email,
                                      javax.mail.internet.InternetAddress address)
                               throws DatabaseException

  Description copied from interface: `EmailCustomizer`
  this method is called by the `EmailAccount.send()` method to individualize this particular email for given the address.

  Specified by:
    `individualizeEmail` in interface `EmailCustomizer`
  Returns:
    true only if the email is to be actually sent; false otherwise (in which case the given email to this address will be skipped)
  Throws:
    `DatabaseException` - if something went wrong when trying to access relevant data for the customization
  See Also:
    `POP3Account.sendEmails(Email, InternetAddress[], EmailCustomizer, com.antelmann.util.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) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads