Project Wonder 2.0

er.javamail
Class ERMailDelivery

java.lang.Object
  extended byer.javamail.ERMailDelivery
Direct Known Subclasses:
ERMailDeliveryComponentBased, ERMailDeliveryPlainText

public abstract class ERMailDelivery
extends Object

This is the main class for sending mail with the JavaMail API. You typically don't create instances of this class since it is abstract. You should create instances of its subclasses that fitted with specifical use cases.
Here is an example of its usage.

ERMailDeliveryHTML mail = new ERMailDeliveryHTML ();
mail.setWOComponentContent (mailPage);

try {
    mail.newMail ();
    mail.setFromAddress    (emailFrom);
    mail.setReplyToAddress (emailReplyTo);
    mail.setSubject 	   (emailSubject);
    mail.setToAddresses    (new NSArray (toEmailAddresses));

    // Send the mail
    mail.sendMail ();
} catch (Exception e) {
    // do something ...
}

Author:
Camille Troillard

Field Summary
protected  NSMutableArray _attachments
          NSArray of ERMailAttachment that must be binded to the message as ATTACHEMENT.
 Object _callbackObject
          Deprecated.  
 String _charset
           
protected  NSMutableArray _inlineAttachments
          NSArray of ERMailAttachment that must be binded to the message as INLINE.
protected  javax.mail.internet.MimeMessage _mimeMessage
          Content of sent mail.
static String callBackClassName
          Deprecated.  
static String callBackMethodName
          Deprecated.  
static String DefaultCharset
           
 
Constructor Summary
ERMailDelivery()
          Default constructor
ERMailDelivery(javax.mail.Session session)
          Designated constructor
 
Method Summary
protected  NSMutableArray _attachments()
           
protected  NSMutableArray _inlineAttachments()
           
 void addAttachment(ERMailAttachment attachment)
           
 void addInlineAttachment(ERMailAttachment attachment)
           
 NSArray attachments()
           
protected  ERMessage buildMessage()
          Builds an ERMessage for the current MimeMessage.
 Object callbackObject()
          Deprecated.  
 String charset()
           
protected  void finishMessagePreparation()
           
 NSArray inlineAttachments()
           
protected  javax.mail.internet.InternetAddress internetAddressWithEmailAndPersonal(String email, String personal)
           
protected  javax.mail.internet.MimeMessage mimeMessage()
           
 void newMail()
          Creates a new mail instance within ERMailDelivery
protected abstract  javax.activation.DataHandler prepareMail()
          Abstract method called by subclasses for doing pre-processing before sending the mail.
 void removeAttachment(ERMailAttachment attachment)
           
 void sendMail()
          Sends the mail immediately.
 void sendMail(boolean shouldBlock)
          Method used to construct a MimeMessage and then send it.
protected  javax.mail.Session session()
           
 void setBCCAddresses(NSArray bccAddresses)
          Sets the bcc-addresses array for the current message instance
static void setCallBackClassWithMethod(String className, String methodName)
          Deprecated.  
 void setCallbackObject(Object obj)
          Deprecated.  
 void setCCAddresses(NSArray ccAddresses)
          Sets the cc-addresses array for the current message instance
 void setCharset(String charset)
           
 void setFromAddress(String fromAddress)
          Sets the from address for the current message instance
 void setFromAddress(String fromAddress, String personalName)
          Sets the from address for the current message instance using an email and the personal name.
 void setInternetAddresses(NSArray addresses, javax.mail.Message.RecipientType type)
          Sets addresses using an NSArray of InternetAddress objects.
protected  void setMimeMessage(javax.mail.internet.MimeMessage message)
           
 void setReplyToAddress(String replyToAddress)
          Sets the reply-to address for the current message instance
protected  void setSession(javax.mail.Session aSession)
           
 void setSubject(String subject)
          Sets the subject for the current message instance
 void setToAddress(String toAddress)
           
 void setToAddress(String toAddress, String personalName)
          Sets the to address for the current message instance using an email and the personal name.
 void setToAddresses(NSArray toAddresses)
          Sets the to-addresses array for the current message instance
 void setXMailerHeader(String xMailer)
          Sets the X-Mailer header for the message.
 String xMailerHeader()
          Gets the X-Mailer header set on the MimeMessage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_mimeMessage

protected javax.mail.internet.MimeMessage _mimeMessage
Content of sent mail. In one instance of OMailDelivery, when creating multiple mails, you must be sure to call newMail () method before send a new mail in order to have a cleared fresh mail


_attachments

protected NSMutableArray _attachments
NSArray of ERMailAttachment that must be binded to the message as ATTACHEMENT.


_inlineAttachments

protected NSMutableArray _inlineAttachments
NSArray of ERMailAttachment that must be binded to the message as INLINE.


callBackClassName

public static String callBackClassName
Deprecated.  

Callback class name. Used to have ERMail call a method on a class after a message has been sent


callBackMethodName

public static String callBackMethodName
Deprecated.  


DefaultCharset

public static String DefaultCharset

_charset

public String _charset

_callbackObject

public Object _callbackObject
Deprecated.  

callbackObject to refer to in the calling program

Constructor Detail

ERMailDelivery

public ERMailDelivery(javax.mail.Session session)
Designated constructor


ERMailDelivery

public ERMailDelivery()
Default constructor

Method Detail

setCallBackClassWithMethod

public static void setCallBackClassWithMethod(String className,
                                              String methodName)
Deprecated.  

Sets the callback class and method name


charset

public String charset()

setCharset

public void setCharset(String charset)

session

protected javax.mail.Session session()

setSession

protected void setSession(javax.mail.Session aSession)

newMail

public void newMail()
Creates a new mail instance within ERMailDelivery


mimeMessage

protected javax.mail.internet.MimeMessage mimeMessage()

setMimeMessage

protected void setMimeMessage(javax.mail.internet.MimeMessage message)

addAttachment

public void addAttachment(ERMailAttachment attachment)

addInlineAttachment

public void addInlineAttachment(ERMailAttachment attachment)

_inlineAttachments

protected NSMutableArray _inlineAttachments()

inlineAttachments

public NSArray inlineAttachments()

_attachments

protected NSMutableArray _attachments()

attachments

public NSArray attachments()

removeAttachment

public void removeAttachment(ERMailAttachment attachment)

internetAddressWithEmailAndPersonal

protected javax.mail.internet.InternetAddress internetAddressWithEmailAndPersonal(String email,
                                                                                  String personal)
                                                                           throws javax.mail.internet.AddressException
Throws:
javax.mail.internet.AddressException

setFromAddress

public void setFromAddress(String fromAddress)
                    throws javax.mail.MessagingException,
                           javax.mail.internet.AddressException
Sets the from address for the current message instance

Throws:
javax.mail.MessagingException
javax.mail.internet.AddressException

setFromAddress

public void setFromAddress(String fromAddress,
                           String personalName)
                    throws javax.mail.MessagingException,
                           javax.mail.internet.AddressException
Sets the from address for the current message instance using an email and the personal name.

Throws:
javax.mail.MessagingException
javax.mail.internet.AddressException

setToAddress

public void setToAddress(String toAddress)
                  throws javax.mail.MessagingException,
                         javax.mail.internet.AddressException
Throws:
javax.mail.MessagingException
javax.mail.internet.AddressException

setToAddress

public void setToAddress(String toAddress,
                         String personalName)
                  throws javax.mail.MessagingException,
                         javax.mail.internet.AddressException
Sets the to address for the current message instance using an email and the personal name.

Throws:
javax.mail.MessagingException
javax.mail.internet.AddressException

setToAddresses

public void setToAddresses(NSArray toAddresses)
                    throws javax.mail.MessagingException,
                           javax.mail.internet.AddressException
Sets the to-addresses array for the current message instance

Throws:
javax.mail.MessagingException
javax.mail.internet.AddressException

setReplyToAddress

public void setReplyToAddress(String replyToAddress)
                       throws javax.mail.MessagingException,
                              javax.mail.internet.AddressException
Sets the reply-to address for the current message instance

Throws:
javax.mail.MessagingException
javax.mail.internet.AddressException

setCCAddresses

public void setCCAddresses(NSArray ccAddresses)
                    throws javax.mail.MessagingException,
                           javax.mail.internet.AddressException
Sets the cc-addresses array for the current message instance

Throws:
javax.mail.MessagingException
javax.mail.internet.AddressException

setBCCAddresses

public void setBCCAddresses(NSArray bccAddresses)
                     throws javax.mail.MessagingException,
                            javax.mail.internet.AddressException
Sets the bcc-addresses array for the current message instance

Throws:
javax.mail.MessagingException
javax.mail.internet.AddressException

setCallbackObject

public void setCallbackObject(Object obj)
Deprecated.  

Sets the object for the message. This is the identifying object from the calling program.


callbackObject

public Object callbackObject()
Deprecated.  


setSubject

public void setSubject(String subject)
                throws javax.mail.MessagingException
Sets the subject for the current message instance

Throws:
javax.mail.MessagingException

setXMailerHeader

public void setXMailerHeader(String xMailer)
                      throws javax.mail.MessagingException
Sets the X-Mailer header for the message. Useful for tracking which mailers are sending messages.

Parameters:
xMailer - value to set
Throws:
javax.mail.MessagingException

xMailerHeader

public String xMailerHeader()
                     throws javax.mail.MessagingException
Gets the X-Mailer header set on the MimeMessage.

Returns:
X-Mailer header if it is set
Throws:
javax.mail.MessagingException

buildMessage

protected ERMessage buildMessage()
Builds an ERMessage for the current MimeMessage.

Returns:
ERMessage for the current MimeMessage.

sendMail

public void sendMail()
Sends the mail immediately. The message is put in a FIFO queue managed by a static threaded inner class


sendMail

public void sendMail(boolean shouldBlock)
Method used to construct a MimeMessage and then send it. This method can be specified to block until the message is sent or to add the message to a queue and have a callback object handle any exceptions that happen. If sending is blocking then any exception thrown will be wrapped in a general NSForwardException.

Parameters:
shouldBlock - boolean to indicate if the message should be added to a queue or sent directly.

finishMessagePreparation

protected void finishMessagePreparation()
                                 throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

setInternetAddresses

public void setInternetAddresses(NSArray addresses,
                                 javax.mail.Message.RecipientType type)
                          throws javax.mail.MessagingException
Sets addresses using an NSArray of InternetAddress objects. This method, unlike 'setAddresses' does not have the ability to filter black & white list.

Throws:
javax.mail.MessagingException

prepareMail

protected abstract javax.activation.DataHandler prepareMail()
                                                     throws javax.mail.MessagingException
Abstract method called by subclasses for doing pre-processing before sending the mail.

Returns:
the multipart used to put in the mail.
Throws:
javax.mail.MessagingException

Last updated: Do, Dez 9, 2004 • 12:46 PM CET

Copyright © 2002 – 2004 Project Wonder.