Project Wonder 5.0

er.javamail
Class ERMailUtils

java.lang.Object
  extended by er.javamail.ERMailUtils

public class ERMailUtils
extends java.lang.Object

ERMailUtils contains various utility method related to mail sending.

Version:
$Id$
Author:
Camille Troillard

Constructor Summary
ERMailUtils()
           
 
Method Summary
static com.webobjects.foundation.NSArray<java.lang.String> convertInternetAddressesToNSArray(javax.mail.Address[] addressesArray)
          Method that converts Address [] loaded with either Address or InternetAddress objects to NSArray of String emails.
static javax.mail.internet.InternetAddress[] convertNSArrayToInternetAddresses(com.webobjects.foundation.NSArray addrs)
          Method that converts NSArray of String emails to InternetAddress [].
static javax.mail.internet.InternetAddress[] convertNSDictionaryToInternetAddresses(com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.String> addrs, java.lang.String charset)
          Method that converts NSDictionary consisting of String emails as keys and String personal names to InternetAddress [].
static java.lang.String encodeString(java.lang.String string, java.lang.String charset)
           
static com.webobjects.appserver.WOComponent instantiatePage(java.lang.String pageName, com.webobjects.foundation.NSDictionary sessionDict)
          Augmented version of the method found in ERXApplication.
static void sendHTMLMail(ERMailDeliveryHTML delivery, java.lang.String pageName, java.lang.String alternatePageName, java.lang.String emailFrom, java.lang.String emailTo, java.lang.String emailReplyTo, java.lang.String subject)
          Use this method to send an HTML mail.
static void sendHTMLMail(java.lang.String pageName, java.lang.String alternatePageName, java.lang.String emailFrom, java.lang.String emailTo, java.lang.String emailReplyTo, java.lang.String subject)
          Use this method to send an HTML mail, but default mail delivery.
static void setDictionaryValuesInSession(com.webobjects.foundation.NSDictionary dict, com.webobjects.appserver.WOSession session)
          This method sets the values found in a dictionary into the session's state dictionary.
static ERMailDeliveryHTML sharedDeliverer()
          Accessor to the shared instance of a ERMailDeliveryHTML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ERMailUtils

public ERMailUtils()
Method Detail

sharedDeliverer

public static ERMailDeliveryHTML sharedDeliverer()
Accessor to the shared instance of a ERMailDeliveryHTML.

Returns:
the ERMailDeliveryHTML singleton

instantiatePage

public static com.webobjects.appserver.WOComponent instantiatePage(java.lang.String pageName,
                                                                   com.webobjects.foundation.NSDictionary sessionDict)
Augmented version of the method found in ERXApplication. Used to instantiate a WOComponent, typically outside of a session.

Parameters:
pageName - The name of the WOComponent that must be instantiated.
sessionDict - can be provided in order to set objects/keys in the newly created session of the component. This is useful when one want to preserve state when sending a mail.
Returns:
a newly instantiated WOComponent.

sendHTMLMail

public static void sendHTMLMail(ERMailDeliveryHTML delivery,
                                java.lang.String pageName,
                                java.lang.String alternatePageName,
                                java.lang.String emailFrom,
                                java.lang.String emailTo,
                                java.lang.String emailReplyTo,
                                java.lang.String subject)
Use this method to send an HTML mail.

Parameters:
delivery - the ERMailDeliveryHTML used to send the mail.
pageName - The name of the WOComponent that must be instantiated.
alternatePageName - The name of the WOComponent that represents for the text that must be displayed when an alternate plain text version of the mail needs to be provided.
emailFrom - the email address the mail is sent from
emailTo - the email address the mail is sent to
emailReplyTo - the email address where the mail must be replied-to.
subject - the subject of the mail

sendHTMLMail

public static void sendHTMLMail(java.lang.String pageName,
                                java.lang.String alternatePageName,
                                java.lang.String emailFrom,
                                java.lang.String emailTo,
                                java.lang.String emailReplyTo,
                                java.lang.String subject)
Use this method to send an HTML mail, but default mail delivery.

Parameters:
pageName - The name of the WOComponent that must be instantiated.
alternatePageName - The name of the WOComponent that represents for the text that must be displayed when an alternate plain text version of the mail needs to be provided.
emailFrom - the email address the mail is sent from
emailTo - the email address the mail is sent to
emailReplyTo - the email address where the mail must be replied-to.
subject - the subject of the mail

setDictionaryValuesInSession

public static void setDictionaryValuesInSession(com.webobjects.foundation.NSDictionary dict,
                                                com.webobjects.appserver.WOSession session)
This method sets the values found in a dictionary into the session's state dictionary. This method is useful when one want to transfer current session's state into a newly created session (for example when sending a mail whose page has been instantiated with ERMailUtils.instantiatePage or ERXApplication.instantiatePage.)

Parameters:
dict - a NSDictionary value containing the values we want to set in the session parameter.
session - a WOSession value that will receive the values contained in the dict parameter.

encodeString

public static java.lang.String encodeString(java.lang.String string,
                                            java.lang.String charset)

convertNSArrayToInternetAddresses

public static javax.mail.internet.InternetAddress[] convertNSArrayToInternetAddresses(com.webobjects.foundation.NSArray addrs)
                                                                               throws javax.mail.internet.AddressException
Method that converts NSArray of String emails to InternetAddress [].

Parameters:
addrs - a NSArray value
Returns:
an InternetAddress[] value
Throws:
javax.mail.internet.AddressException - if an error occurs

convertInternetAddressesToNSArray

public static com.webobjects.foundation.NSArray<java.lang.String> convertInternetAddressesToNSArray(javax.mail.Address[] addressesArray)
Method that converts Address [] loaded with either Address or InternetAddress objects to NSArray of String emails.

Note that this method will not only accept Address [] but also InternetAddress [].

Parameters:
addressesArray - an Address[] value
Returns:
a NSArray value
Throws:
javax.mail.internet.AddressException - if an error occurs

convertNSDictionaryToInternetAddresses

public static javax.mail.internet.InternetAddress[] convertNSDictionaryToInternetAddresses(com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.String> addrs,
                                                                                           java.lang.String charset)
                                                                                    throws javax.mail.internet.AddressException
Method that converts NSDictionary consisting of String emails as keys and String personal names to InternetAddress [].

Parameters:
addrs - a NSDictionary with email, personal name as key value pair
charset - a String of the charset to use for personal string
Returns:
an InternetAddress[] value
Throws:
javax.mail.internet.AddressException - if an error occurs

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.