public static class Email.Builder extends Object
| Modifier and Type | Field and Description |
|---|---|
private List<AttachmentResource> |
attachments
List of
AttachmentResource. |
private Email |
email |
private List<AttachmentResource> |
embeddedImages
List of
AttachmentResource. |
private Recipient |
fromRecipient |
private Map<String,String> |
headers
Map of header name and values, such as
X-Priority etc. |
private List<Recipient> |
recipients
List of
Recipient. |
private Recipient |
replyToRecipient
The reply-to-address, optional.
|
private String |
subject
The subject of the email message.
|
private String |
text
The email message body in plain text.
|
private String |
textHTML
The email message body in html.
|
| Constructor and Description |
|---|
Builder() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAttachment(String name,
byte[] data,
String mimetype)
Adds an attachment to the email message and generates the necessary
DataSource with the given byte data. |
void |
addAttachment(String name,
DataSource filedata)
Overloaded method which sets an attachment on account of name and
DataSource. |
Email.Builder |
addHeader(String name,
Object value)
Adds a header to the
headers list. |
Email.Builder |
bcc(Recipient recipient)
Adds a new
Recipient to the list on account of name, address with recipient type Message.RecipientType.BCC. |
Email.Builder |
bcc(String name,
String address)
Adds a new
Recipient to the list on account of name, address with recipient type Message.RecipientType.BCC. |
Email |
build() |
Email.Builder |
cc(Recipient recipient)
Adds a new
Recipient to the list on account of name, address with recipient type Message.RecipientType.CC. |
Email.Builder |
cc(String name,
String address)
Adds a new
Recipient to the list on account of name, address with recipient type Message.RecipientType.CC. |
Email.Builder |
embedImage(String name,
byte[] data,
String mimetype)
Adds an embedded image (attachment type) to the email message and generates the necessary
DataSource with the given byte
data. |
Email.Builder |
embedImage(String name,
DataSource imagedata)
Overloaded method which sets an embedded image on account of name and
DataSource. |
Email.Builder |
from(String name,
String fromAddress)
Sets the sender address.
|
Email.Builder |
replyTo(String name,
String replyToAddress)
Sets the reply-to address (optional).
|
Email.Builder |
subject(String subject)
Sets the
subject. |
Email.Builder |
text(String text)
Sets the
text. |
Email.Builder |
textHTML(String textHTML)
Sets the
textHTML. |
Email.Builder |
to(Recipient recipient)
Adds a new
Recipient to the list on account of name, address with recipient type Message.RecipientType.TO. |
Email.Builder |
to(String name,
String address)
Adds a new
Recipient to the list on account of name, address with recipient type Message.RecipientType.TO. |
private Recipient fromRecipient
private Recipient replyToRecipient
fromRecipient.private final List<Recipient> recipients
Recipient.private final List<AttachmentResource> embeddedImages
AttachmentResource.private final List<AttachmentResource> attachments
AttachmentResource.private final Map<String,String> headers
X-Priority etc.public Builder()
public Email.Builder from(String name, String fromAddress)
name - The sender's name.fromAddress - The sender's email address.public Email.Builder replyTo(String name, String replyToAddress)
name - The replied-to-receiver name.replyToAddress - The replied-to-receiver email address.public Email.Builder subject(String subject)
subject.public Email.Builder text(String text)
text.public Email.Builder textHTML(String textHTML)
textHTML.public Email.Builder to(String name, String address)
Recipient to the list on account of name, address with recipient type Message.RecipientType.TO.name - The name of the recipient.address - The emailaddress of the recipient.recipients,
Recipientpublic Email.Builder to(Recipient recipient)
Recipient to the list on account of name, address with recipient type Message.RecipientType.TO.recipient - The recipent whose name and address to userecipients,
Recipientpublic Email.Builder cc(String name, String address)
Recipient to the list on account of name, address with recipient type Message.RecipientType.CC.name - The name of the recipient.address - The emailaddress of the recipient.recipients,
Recipientpublic Email.Builder cc(Recipient recipient)
Recipient to the list on account of name, address with recipient type Message.RecipientType.CC.recipient - The recipent whose name and address to userecipients,
Recipientpublic Email.Builder bcc(String name, String address)
Recipient to the list on account of name, address with recipient type Message.RecipientType.BCC.name - The name of the recipient.address - The emailaddress of the recipient.recipients,
Recipientpublic Email.Builder bcc(Recipient recipient)
Recipient to the list on account of name, address with recipient type Message.RecipientType.BCC.recipient - The recipent whose name and address to userecipients,
Recipientpublic Email.Builder embedImage(String name, byte[] data, String mimetype)
DataSource with the given byte
data. Then delegates to Email.addEmbeddedImage(String, DataSource). At this point the datasource is actually a
ByteArrayDataSource.name - The name of the image as being referred to from the message content body (eg. '<cid:signature>').data - The byte data of the image to be embedded.mimetype - The content type of the given data (eg. "image/gif" or "image/jpeg").ByteArrayDataSource,
Email.addEmbeddedImage(String, DataSource)public Email.Builder embedImage(String name, DataSource imagedata)
DataSource.name - The name of the image as being referred to from the message content body (eg. '<cid:embeddedimage>').imagedata - The image data.public Email.Builder addHeader(String name, Object value)
headers list. The value is stored as a String.
example: email.addHeader("X-Priority", 2)
name - The name of the header.value - The value of the header, which will be stored using String.valueOf(Object).public void addAttachment(String name, byte[] data, String mimetype)
DataSource with the given byte data. Then delegates to
addAttachment(String, DataSource). At this point the datasource is actually a ByteArrayDataSource.name - The name of the extension (eg. filename including extension).data - The byte data of the attachment.mimetype - The content type of the given data (eg. "plain/text", "image/gif" or "application/pdf").ByteArrayDataSource,
addAttachment(String, DataSource)public void addAttachment(String name, DataSource filedata)
DataSource.name - The name of the attachment (eg. 'filename.ext').filedata - The attachment data.Copyright © 2009 under Apache v2 license.