public class MailBuilder extends Object
| Modifier and Type | Method and Description |
|---|---|
MailBuilder |
attach(File file)
Add an attachment to the MimeMessage, taking the content from a
java.io.File. |
MailBuilder |
attach(String name,
File file)
Add an attachment to the MimeMessage, taking the content from a
java.io.File. |
MailBuilder |
attach(String name,
InputStream input,
String contentType)
Add an attachment to the MimeMessage.
|
MailBuilder |
attach(String name,
org.springframework.core.io.Resource resource,
String contentType)
Add an attachment to the MimeMessage.
|
MailBuilder |
bcc(Iterable<String> bcc)
Set 'bcc' with the provided email addresses.
|
MailBuilder |
bcc(String... bcc)
Set 'bcc' with the provided email addresses.
|
javax.mail.internet.MimeMessage |
build()
Return a
MimeMessage ready to be send. |
MailBuilder |
cc(Iterable<String> cc)
Set cc with the provided email addresses.
|
MailBuilder |
cc(String... cc)
Set cc with the provided email addresses.
|
MailBuilder |
from(String from)
Set 'from' with the provided email address.
|
MailBuilder |
from(String from,
String name)
Set 'from' with the provided email address.
|
MailBuilder |
html(String html,
Object... args)
Set the given text directly as content in non-multipart mode
or as default body part in multipart mode.
|
static InputStream |
mailInputStream(InputStream input,
String contentType)
Add content-type information to an
InputStream. |
static MailBuilder |
newMail(org.springframework.mail.javamail.JavaMailSender sender)
Creates a new mail message with multi-part support and UTF-8 encoding.
|
static MailBuilder |
newMail(org.springframework.mail.javamail.JavaMailSender sender,
String encoding)
Creates a new mail message with multi-part support and the specified
encoding.
|
static MailBuilder |
newSimpleMail(org.springframework.mail.javamail.JavaMailSender sender)
Creates a new simple mail message without multi-part support.
|
MailBuilder |
replyTo(String replayTo)
Set 'replayTo' with the provided email address.
|
MailBuilder |
replyTo(String replayTo,
String name)
Set 'replayTo' with the provided email address.
|
MailBuilder |
subject(String subject)
Set 'subject' of the message.
|
MailBuilder |
text(String text,
Object... args)
Set the given text directly as content.
|
MailBuilder |
to(Iterable<String> to)
Set 'to' with the provided email addresses.
|
MailBuilder |
to(String... to)
Set 'to' with the provided email addresses.
|
public MailBuilder text(String text, Object... args) throws javax.mail.MessagingException
Usage:
text("Hello {0}!", "World");
text - The text for the message.MailBuilder.javax.mail.MessagingException - in case of errors.MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)public MailBuilder to(String... to) throws javax.mail.MessagingException
to - The email addresses.MailBuilder.javax.mail.MessagingExceptionpublic MailBuilder to(Iterable<String> to) throws javax.mail.MessagingException
to - The email addresses.MailBuilder.javax.mail.MessagingExceptionpublic MailBuilder bcc(String... bcc) throws javax.mail.MessagingException
bcc - The email addresses.MailBuilder.javax.mail.MessagingExceptionpublic MailBuilder bcc(Iterable<String> bcc) throws javax.mail.MessagingException
bcc - The email addresses.MailBuilder.javax.mail.MessagingExceptionpublic MailBuilder cc(String... cc) throws javax.mail.MessagingException
cc - The email addresses.MailBuilder.javax.mail.MessagingExceptionpublic MailBuilder cc(Iterable<String> cc) throws javax.mail.MessagingException
cc - The email addresses.MailBuilder.javax.mail.MessagingExceptionpublic MailBuilder from(String from) throws javax.mail.MessagingException
from - The email address.MailBuilder.javax.mail.MessagingExceptionpublic MailBuilder from(String from, String name) throws javax.mail.MessagingException, UnsupportedEncodingException
from - The email address.name - The personal name.MailBuilder.javax.mail.MessagingExceptionUnsupportedEncodingExceptionpublic MailBuilder replyTo(String replayTo) throws javax.mail.MessagingException
replayTo - The email address.MailBuilder.javax.mail.MessagingExceptionpublic MailBuilder replyTo(String replayTo, String name) throws javax.mail.MessagingException, UnsupportedEncodingException
replayTo - The email address.name - The personal name.MailBuilder.javax.mail.MessagingExceptionUnsupportedEncodingExceptionpublic MailBuilder subject(String subject) throws javax.mail.MessagingException
subject - The email address.MailBuilder.javax.mail.MessagingExceptionpublic MailBuilder html(String html, Object... args) throws javax.mail.MessagingException, IOException
Usage:
html("<img src=\"{0}\">"<p>Hello {1}!</p>,
new File("header.jpg"),
"World");
Or:
html("<img src=\"{0}\">"<p>Hello {1}!</p>,
MailBuilder.mailInputStream(source, "image/jpg"),
"World");
html - The html code as string.args - The embedded elements. Optional.MailBuilder.javax.mail.MessagingException - If something goes wrong.IOException - If the embedded/inline resource cannot be read it.public MailBuilder attach(String name, File file) throws javax.mail.MessagingException
java.io.File.
The content type will be determined by the name of the given content file. Do not use this for temporary files with arbitrary filenames (possibly ending in ".tmp" or the like)!
name - The attachment name.file - The resource to add.MailBuilder.javax.mail.MessagingException - If something goes wrong.public MailBuilder attach(File file) throws javax.mail.MessagingException
java.io.File.
The content type will be determined by the name of the given content file. Do not use this for temporary files with arbitrary filenames (possibly ending in ".tmp" or the like)!
file - The resource to add.MailBuilder.javax.mail.MessagingException - If something goes wrong.public MailBuilder attach(String name, InputStream input, String contentType) throws javax.mail.MessagingException, IOException
name - The attachment name.input - The resource to add.contentType - The resource content type.MailBuilder.javax.mail.MessagingException - If something goes wrong.IOException - If something goes wrong.public MailBuilder attach(String name, org.springframework.core.io.Resource resource, String contentType) throws javax.mail.MessagingException
name - The attachment name.resource - The resource to add.contentType - The resource content type.MailBuilder.javax.mail.MessagingException - If something goes wrong.public javax.mail.internet.MimeMessage build()
MimeMessage ready to be send.MimeMessage fully configured.public static MailBuilder newMail(org.springframework.mail.javamail.JavaMailSender sender, String encoding) throws javax.mail.MessagingException
sender - The email sender. Required.encoding - The encoding. Required.javax.mail.MessagingException - If the message cannot be created.public static MailBuilder newMail(org.springframework.mail.javamail.JavaMailSender sender) throws javax.mail.MessagingException
sender - The email sender. Required.javax.mail.MessagingException - If the message cannot be created.public static MailBuilder newSimpleMail(org.springframework.mail.javamail.JavaMailSender sender) throws javax.mail.MessagingException
sender - The email sender. Required.javax.mail.MessagingException - If the message cannot be created.public static InputStream mailInputStream(InputStream input, String contentType)
InputStream.input - The candidate input stream. Required.contentType - The content-type. Required.Copyright © 2013. All Rights Reserved.