|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.dspace.core.Email
public class Email
Class representing an e-mail message, also used to send e-mails.
Typical use:
Email email = ConfigurationManager.getEmail(name);
email.addRecipient("foo@bar.com");
email.addArgument("John");
email.addArgument("On the Testing of DSpace");
email.send();
name is the name of an email template in
dspace-dir/config/emails/ (which also includes the subject.)
arg0 and arg1 are arguments to fill out the
message with.
Emails are formatted using java.text.MessageFormat.
Additionally, comment lines (starting with '#') are stripped, and if a line
starts with "Subject:" the text on the right of the colon is used for the
subject line. For example:
# This is a comment line which is stripped
#
# Parameters: {0} is a person's name
# {1} is the name of a submission
#
Subject: Example e-mail
Dear {0},
Thank you for sending us your submission "{1}".
If the example code above was used to send this mail, the resulting mail
would have the subject Example e-mail and the body would be:
Dear John,
Thank you for sending us your submission "On the Testing of DSpace".
Note that parameters like {0} cannot be placed in the subject
of the e-mail; they won't get filled out.
| Method Summary | |
|---|---|
void |
addArgument(Object arg)
Fill out the next argument in the template |
void |
addAttachment(File f,
String name)
|
void |
addRecipient(String email)
Add a recipient |
void |
reset()
"Reset" the message. |
void |
send()
Sends the email. |
void |
setCharset(String cs)
|
void |
setReplyTo(String email)
Set the reply-to email address |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public void addRecipient(String email)
email - the recipient's email addresspublic void setReplyTo(String email)
email - the reply-to email addresspublic void addArgument(Object arg)
arg - the value for the next argument
public void addAttachment(File f,
String name)
public void setCharset(String cs)
public void reset()
public void send()
throws javax.mail.MessagingException
javax.mail.MessagingException - if there was a problem sending the mail.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||