org.olat.core.util.mail
Class MailerWithTemplate

java.lang.Object
  extended by org.olat.core.util.mail.MailerWithTemplate

public class MailerWithTemplate
extends java.lang.Object

Description:
Helper class for managing email templates

Initial Date: 21.11.2006

Author:
Florian Gnaegi, frentix GmbH
http://www.frentix.com

Method Summary
static MailerWithTemplate getInstance()
           
 java.lang.String[] previewSubjectAndBody(Identity recipientTO, java.util.List<Identity> recipientsCC, java.util.List<Identity> recipientsBCC, MailTemplate template, Identity sender)
          creates the subject and body for a preview.
 MailerResult sendMail(Identity recipientTO, java.util.List<Identity> recipientsCC, java.util.List<Identity> recipientsBCC, MailTemplate template, Identity sender)
          Send a mail to the given identity and the other recipients (CC and BCC) using the template.
 MailerResult sendMailAsSeparateMails(java.util.List<Identity> recipientsTO, java.util.List<Identity> recipientsCC, java.util.List<Identity> recipientsBCC, MailTemplate template, Identity sender)
          Send a mail to the given identities (TO, CC and BCC) using the template.
 MailerResult sendMailUsingTemplateContext(Identity recipientTO, java.util.List<Identity> recipientsCC, java.util.List<Identity> recipientsBCC, MailTemplate template, Identity sender)
          Send email and use the given template-context.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static MailerWithTemplate getInstance()
Returns:
MailerWithTemplate returns the singleton instance

sendMailUsingTemplateContext

public MailerResult sendMailUsingTemplateContext(Identity recipientTO,
                                                 java.util.List<Identity> recipientsCC,
                                                 java.util.List<Identity> recipientsBCC,
                                                 MailTemplate template,
                                                 Identity sender)
Send email and use the given template-context.

Parameters:
recipientTO -
recipientsCC -
recipientsBCC -
template -
sender -
Returns:

previewSubjectAndBody

public java.lang.String[] previewSubjectAndBody(Identity recipientTO,
                                                java.util.List<Identity> recipientsCC,
                                                java.util.List<Identity> recipientsBCC,
                                                MailTemplate template,
                                                Identity sender)
creates the subject and body for a preview.

Parameters:
recipientTO -
recipientsCC -
recipientsBCC -
template -
sender -
Returns:
String[] with index 0 is subject, and index 1 is body

sendMail

public MailerResult sendMail(Identity recipientTO,
                             java.util.List<Identity> recipientsCC,
                             java.util.List<Identity> recipientsBCC,
                             MailTemplate template,
                             Identity sender)
Send a mail to the given identity and the other recipients (CC and BCC) using the template. The mail is sent as identity sender.

The method uses sendMailAsSeparateMails to send the message. If you have multiple identities to which you need to send the same mail, use the sendMailAsSeparateMails message and not this one

Parameters:
recipientTO - Identity for TO. Must not be NULL
recipientsCC - Identities List for CC. Can be NULL.
recipientsBCC - Identities List for BCC. Can be NULL
template - Mail template. Must not be NULL
sender - The senders identity. Can be NULL. In case of NULL the systems send mail configuraton is used
Returns:
MailerResult with status and list of identites that could not be mailed to

sendMailAsSeparateMails

public MailerResult sendMailAsSeparateMails(java.util.List<Identity> recipientsTO,
                                            java.util.List<Identity> recipientsCC,
                                            java.util.List<Identity> recipientsBCC,
                                            MailTemplate template,
                                            Identity sender)
Send a mail to the given identities (TO, CC and BCC) using the template. The mail is sent as identity sender.

The template is parsed for every identity in the TO list. For each of those identities a separate mail is sent. Use this only if the mail content differ for each identity. Otherwhise use the sendMailAsOneMail method.

In this method the recipients will not know who else got the mail since the mail is addressed personally.

Parameters:
recipientsTO - Identities List for TO. Must not be NULL and contain at least one identity.
recipientsCC - Identities List for CC. Can be NULL.
recipientsBCC - Identities List for BCC. Can be NULL
template - Mail template. Must not be NULL
sender - The senders identity. Can be NULL. In case of NULL the systems send mail configuraton is used
Returns:
MailerResult with status and list of identites that could not be mailed to