|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jalios.jcms.MailMessage
public class MailMessage
Class used to build and send a mail message.
Example :
MailMessage msg = new MailMessage("myplugin.log-mail"); msg.setTo(channel.getDefaultAdmin()) .setSubject("[" + channel.getName() + "] Daily log") .setContentText("Daily log attached") .addFile(new File(channel.getRealPath("WEB-INF/data/logs/jcms.log"))) .send(); logger.info("Log mail sent in " + Util.formatDuration(msg.getDuration()));
MailMessage msg = new MailMessage("starwarsplugin.war-mail-alert"); msg.setFrom("Darth Vader <dv@deathstar.com>"); msg.setTo("Son <luke@alliance.com>"); msg.setBcc("Palpatine <palpatine@deathstar.com>"); for (Member sithMbr : sithGroup.getMemberSet()) { msg.addCc(sithMbr); } msg.setSubject("I am your father"); msg.setContentText("The Force is with you, young Skywalker. But you are not a Jedi yet."); msg.setContentHtml("The <strong>Force</strong> is with you, young Skywalker. But you are not a Jedi yet."); msg.send();
Field Summary | |
---|---|
protected long |
duration
|
static String |
REVISION
|
Constructor Summary | |
---|---|
MailMessage(String origin)
Builds a new empty MailMessage. |
Method Summary | |
---|---|
MailMessage |
addBcc(Member bccMbr)
Add the specified Member as a "Bcc:" recipient of this MailMessage. |
MailMessage |
addBcc(String bccEmails)
Add the specified emails as "Bcc:" recipient of this MailMessage. |
MailMessage |
addCc(Member ccMbr)
Add the specified Member as a "Cc:" recipient of this MailMessage. |
MailMessage |
addCc(String ccEmails)
Add the specified emails as "Cc:" recipient of this MailMessage. |
MailMessage |
addFile(File file)
Add a file to send with this MailMessage. |
MailMessage |
addFile(File file,
String id)
Add a file to send with this MailMessage. |
MailMessage |
addReplyTo(Member replyToMbr)
Add the specified Member as a "ReplyTo:" of this MailMessage. |
MailMessage |
addReplyTo(String replyToEmails)
Add the specified emails as "ReplyTo:" of this MailMessage. |
MailMessage |
addTo(Member toMbr)
Add the specified Member as a "To:" recipient of this MailMessage. |
MailMessage |
addTo(String toEmails)
Add the specified emails as "To:" recipient of this MailMessage. |
Set<Member> |
getBccMemberSet()
Retrieve the Set of Member that will receive blind copy of this MailMessage. |
Set<String> |
getBccSet()
Retrieve the Set of email addresses recipient blind copies of this MailMessage. |
Set<Member> |
getCcMemberSet()
Retrieve the Set of Member that will receive copy of this MailMessage. |
Set<String> |
getCcSet()
Retrieve the Set of email addresses recipient copies of this MailMessage. |
String |
getContentHtml()
Retrieve the HTML text content of this MailMessage. |
String |
getContentText()
Retrieve the plain text content of this MailMessage. |
long |
getDuration()
Retrieve the time the sending process took to execute. |
Map<File,String> |
getFileMap()
Retrieve the Map of File/id to send in this MailMessage. |
String |
getFrom()
Retrieve the "From" email address of this MailMessage. |
Member |
getFromMember()
Retrieve the Member sender of this MailMessage. |
String |
getOrigin()
Retrieve an identifier indicating the origin of this MailMessage in JCMS. |
int |
getPriority()
Retrieve the Priority of this MailMessage. |
Set<Member> |
getReplyToMemberSet()
Retrieve the Set of Member for ReplyTo this MailMessage. |
Set<String> |
getReplyToSet()
Retrieve the Set of email addresses for ReplyTo of this MailMessage. |
String |
getSubject()
Retrieve the subject of this MailMessage. |
Set<Member> |
getToMemberSet()
Retrieve the Set of Member recipient of this MailMessage. |
Set<String> |
getToSet()
Retrieve the Set of email addresses recipient of this MailMessage. |
void |
send()
Send this MailMessage. |
MailMessage |
setBcc(Member bccMbr)
Set the Member that will receive blind copy of this MailMessage. |
MailMessage |
setBcc(String bccEmails)
Set the email addresses that will receive blind copy of this MailMessage. |
MailMessage |
setCc(Member ccMbr)
Set the Member that will receive copy of this MailMessage. |
MailMessage |
setCc(String ccEmails)
Set the email addresses that will receive copy of this MailMessage. |
MailMessage |
setContentHtml(String textHtml)
Set the HTML text content of this MailMessage. |
MailMessage |
setContentHtmlFromJsp(String jspPath,
Member loggedMember,
String language,
HashMap<Object,Object> requestAttribute,
HashMap<Object,Object> sessionAttribute)
Set the HTML text content of this MailMessage from the rendering of the specified jsp. |
MailMessage |
setContentText(String textPlain)
Set the plain text content of this MailMessage. |
MailMessage |
setContentTextFromJsp(String jspPath,
Member loggedMember,
String language,
HashMap<Object,Object> requestAttribute,
HashMap<Object,Object> sessionAttribute)
Set the plain text content of this MailMessage from the rendering of the specified jsp. |
MailMessage |
setFrom(Member member)
Set the Member sending this MailMessage. |
MailMessage |
setFrom(String from)
Set the email address sender of this MailMessage. |
MailMessage |
setPriority(int priority)
Set the priority of this MailMessage. |
MailMessage |
setReplyTo(Member replyToMbr)
Set the Member ReplyTo of this MailMessage. |
MailMessage |
setReplyTo(String replyToEmails)
Set the email addresses ReplyTo of this MailMessage. |
MailMessage |
setSubject(String subject)
Set the subject of this MailMessage. |
MailMessage |
setTo(Member toMbr)
Set the Member recipient of this MailMessage. |
MailMessage |
setTo(String toEmails)
Set the email addresses recipient of this MailMessage. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String REVISION
protected long duration
Constructor Detail |
---|
public MailMessage(String origin)
origin
- an identifier indicating the feature/origin of this MailMessage
e.g "newsletter"
, "myplugin.mail-alert"
Method Detail |
---|
public String getOrigin()
"newsletter"
public String getFrom()
Default value is the mail returned by Channel.getSenderFullEmail()
"Foo Bar" <foobar@company.com>
public Member getFromMember()
The member only be available if it was set using method setFrom(Member)
"Foo Bar" <foobar@company.com>
public MailMessage setFrom(String from)
Replace any value set using setFrom(Member)
from
- a mail address, e.g "Foo Bar" <foobar@company.com>
public MailMessage setFrom(Member member)
Replace any value set using setFrom(String)
member
- a mail address, e.g "Foo Bar" <foobar@company.com>
public Set<String> getToSet()
This set will only be filled if recipients were added using
method setTo(String)
getToSet()
and getToMemberSet()
do not contains
the same information and may be used simultaneously
public Set<Member> getToMemberSet()
This set will only be filled if recipients of this MailMessage were
specified using method setTo(Member)
}
getToSet()
and getToMemberSet()
do not contains
the same information and may be used simultaneously
public MailMessage setTo(String toEmails)
Replace any value set using setTo(Member)
}
toEmails
- a string containing one or several mail addresses seperated with comma,
e.g "Foo Bar" <foobar@company.com>, "John Smith" <js@company.com>
public MailMessage setTo(Member toMbr)
Replace any value set using setTo(String)
}
toMbr
- the Member recipient of this mail
public MailMessage addTo(String toEmails)
toEmails
- a string containing one or several mail addresses seperated with comma,
e.g "Foo Bar" <foobar@company.com>, "John Smith" <js@company.com>
public MailMessage addTo(Member toMbr)
toMbr
- the Member to add as a "To:" recipient of this mail
public Set<String> getCcSet()
This set will only be filled if recipients copies were added using
method setCc(String)
getCcSet()
and getCcMemberSet()
do not contains
the same information and may be used simultaneously
public Set<Member> getCcMemberSet()
This set will only be filled if Member copies of this MailMessage were
specified using method setCc(Member)
}
getCcSet()
and getCcMemberSet()
do not contains
the same information and may be used simultaneously
public MailMessage setCc(String ccEmails)
Replace any value set using setCc(Member)
}
ccEmails
- a string containing one or several mail addresses seperated with comma,
e.g "Foo Bar" <foobar@company.com>, "John Smith" <js@company.com>
public MailMessage setCc(Member ccMbr)
Replace any value set using setCc(String)
}
ccMbr
- the Member recipient of a copy of this mail
public MailMessage addCc(String ccEmails)
ccEmails
- a string containing one or several mail addresses seperated with comma,
e.g "Foo Bar" <foobar@company.com>, "John Smith" <js@company.com>
public MailMessage addCc(Member ccMbr)
ccMbr
- the Member to add as a "Cc:" recipient of this mail
public Set<String> getBccSet()
This set will only be filled if recipients blind copies were added using
method setCc(String)
getBccSet()
and getBccMemberSet()
do not contains
the same information and may be used simultaneously
public Set<Member> getBccMemberSet()
This set will only be filled if Member blindcopies of this MailMessage were
specified using method setBcc(Member)
}
getBccSet()
and getBccMemberSet()
do not contains
the same information and may be used simultaneously
public MailMessage setBcc(String bccEmails)
Replace any value set using setBcc(Member)
}
bccEmails
- a string containing one or several mail addresses seperated with comma,
e.g "Foo Bar" <foobar@company.com>, "John Smith" <js@company.com>
public MailMessage setBcc(Member bccMbr)
Replace any value set using setBcc(String)
}
bccMbr
- the Member recipient of a blind copy of this mail
public MailMessage addBcc(String bccEmails)
bccEmails
- a string containing one or several mail addresses seperated with comma,
e.g "Foo Bar" <foobar@company.com>, "John Smith" <js@company.com>
public MailMessage addBcc(Member bccMbr)
bccMbr
- the Member to add as a "Bcc:" recipient of this mail
public Set<String> getReplyToSet()
This set will only be filled if replyto were added using
method setReplyTo(String)
public Set<Member> getReplyToMemberSet()
This set will only be filled if ReplyTo of this MailMessage were
specified using method setReplyTo(Member)
}
public MailMessage setReplyTo(String replyToEmails)
Replace any value set using setTo(Member)
}
replyToEmails
- a string containing one or several mail addresses seperated with comma,
e.g "Foo Bar" <foobar@company.com>, "John Smith" <js@company.com>
public MailMessage setReplyTo(Member replyToMbr)
Replace any value set using setTo(String)
}
replyToMbr
- the Member ReplyTo of this mail
public MailMessage addReplyTo(String replyToEmails)
replyToEmails
- a string containing one or several mail addresses seperated with comma,
e.g "Foo Bar" <foobar@company.com>, "John Smith" <js@company.com>
public MailMessage addReplyTo(Member replyToMbr)
replyToMbr
- the Member to add as a "ReplyTo:" of this mail
public String getSubject()
public MailMessage setSubject(String subject)
subject
- the subject to use for this MailMessage
public String getContentText()
public MailMessage setContentText(String textPlain)
textPlain
- the plain text content to use for this MailMessage
public MailMessage setContentTextFromJsp(String jspPath, Member loggedMember, String language, HashMap<Object,Object> requestAttribute, HashMap<Object,Object> sessionAttribute)
jspPath
- a jsp path relative to the webapp root e.g "/custom/jcms/doNotificationText.jsp"
loggedMember
- the Member that will be set as the logged member when invoking jsplanguage
- the language that will be set when invoking jsprequestAttribute
- a HashMap of request attribute available to the jsp executionsessionAttribute
- a HashMap of session attribute available to the jsp execution
public String getContentHtml()
public MailMessage setContentHtml(String textHtml)
textHtml
- the HTML text content to use for this MailMessage
public MailMessage setContentHtmlFromJsp(String jspPath, Member loggedMember, String language, HashMap<Object,Object> requestAttribute, HashMap<Object,Object> sessionAttribute)
jspPath
- a jsp path relative to the webapp root e.g "/custom/jcms/doNotificationText.jsp"
loggedMember
- the Member that will be set as the logged member when invoking jsplanguage
- the language that will be set when invoking jsprequestAttribute
- a HashMap of request attribute available to the jsp executionsessionAttribute
- a HashMap of session attribute available to the jsp execution
public int getPriority()
public MailMessage setPriority(int priority)
priority
- an integer between 1 and 5 included.
5 being the lowest, 3 being the "normal" and 1 the highest priority.
public Map<File,String> getFileMap()
public MailMessage addFile(File file)
file
- a File to send.
public MailMessage addFile(File file, String id)
file
- a File to send.id
- an optionnal identifier for this file
public long getDuration()
public void send() throws javax.mail.MessagingException
javax.mail.MessagingException
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |