|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object magoffin.matt.ma2.util.MailMergeHelper
public class MailMergeHelper
A bean to support MailMerge email sending.
The email templates are handled also in a locale-specific way.
The templatePath
property should be set to the directory
that contains the message templates, and the templateName
should be set to the desired template to use, without any locale in
the name. The performMerge(String, ClassLoader, Map)
will
construct a path to the template resource by inserting the language
before the template extension. For example, if templatePath
is set to mailtemplates
and templateName
set to confirmation.txt
, then for the English language
it will look for a resource in the classpath at
mailtemplates/confirmation_en.txt
.
The configurable properties of this class are:
Field Summary | |
---|---|
static java.lang.String |
MSG_NO_SUBJECT_KEY
The key for the message resource for a "no subject" subject. |
Constructor Summary | |
---|---|
MailMergeHelper()
|
Method Summary | |
---|---|
org.springframework.mail.MailSender |
getMailSender()
|
org.springframework.context.MessageSource |
getMessageSource()
|
org.springframework.mail.SimpleMailMessage |
getMessageTemplate()
|
java.lang.String |
getSubjectMessageKey()
|
java.lang.String |
getTemplateName()
|
java.lang.String |
getTemplatePath()
|
boolean |
isIgnoreMailExceptions()
|
java.lang.String |
performMerge(java.lang.String lang,
java.lang.ClassLoader loader,
java.util.Map<java.lang.String,?> model)
Perform a mail merge. |
void |
send(org.springframework.mail.SimpleMailMessage msg)
Send a mail message. |
void |
sendMerge(java.util.Locale locale,
java.lang.ClassLoader loader,
java.util.Map<java.lang.String,?> model,
org.springframework.mail.SimpleMailMessage msg)
Perform a mail merge and send an email with the result of the merge as the email message text. |
void |
setIgnoreMailExceptions(boolean ignoreMailExceptions)
|
void |
setMailSender(org.springframework.mail.MailSender mailSender)
|
void |
setMessageSource(org.springframework.context.MessageSource messageSource)
|
void |
setMessageTemplate(org.springframework.mail.SimpleMailMessage messageTemplate)
|
void |
setSubjectMessageKey(java.lang.String subjectMessageKey)
|
void |
setTemplateName(java.lang.String templateName)
|
void |
setTemplatePath(java.lang.String templatePath)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String MSG_NO_SUBJECT_KEY
Constructor Detail |
---|
public MailMergeHelper()
Method Detail |
---|
public void sendMerge(java.util.Locale locale, java.lang.ClassLoader loader, java.util.Map<java.lang.String,?> model, org.springframework.mail.SimpleMailMessage msg)
The msg
should have all required fields already set prior to
calling this method. The text
property of the message will be
set to the result of the mail merge. If the msg
has a null
subject, then the subject will be set to the resource message specified by
the subjectMessageKey
of this bean. If subjectMessageKey
is null then the MSG_NO_SUBJECT_KEY
resource message will
be used.
locale
- the locale for the mail merge template. If null the
default Locale will be used.loader
- the class loader to usemodel
- the merge model datamsg
- the mail messagepublic void send(org.springframework.mail.SimpleMailMessage msg)
msg
- the message to send
org.springframework.mail.MailException
- if an error occurspublic java.lang.String performMerge(java.lang.String lang, java.lang.ClassLoader loader, java.util.Map<java.lang.String,?> model)
lang
- the language for the mail merge templateloader
- the class loader to usemodel
- the merge model data
public org.springframework.mail.MailSender getMailSender()
public void setMailSender(org.springframework.mail.MailSender mailSender)
mailSender
- The mailSender to set.public org.springframework.context.MessageSource getMessageSource()
public void setMessageSource(org.springframework.context.MessageSource messageSource)
messageSource
- The messageSource to set.public org.springframework.mail.SimpleMailMessage getMessageTemplate()
public void setMessageTemplate(org.springframework.mail.SimpleMailMessage messageTemplate)
messageTemplate
- The messageTemplate to set.public java.lang.String getSubjectMessageKey()
public void setSubjectMessageKey(java.lang.String subjectMessageKey)
subjectMessageKey
- The subjectMessageKey to set.public java.lang.String getTemplateName()
public void setTemplateName(java.lang.String templateName)
templateName
- The templateName to set.public java.lang.String getTemplatePath()
public void setTemplatePath(java.lang.String templatePath)
templatePath
- The templatePath to set.public boolean isIgnoreMailExceptions()
public void setIgnoreMailExceptions(boolean ignoreMailExceptions)
ignoreMailExceptions
- the ignoreMailExceptions to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |