public class Email extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Email.Builder
Fluent interface Builder for Emails
|
Constructor and Description |
---|
Email()
Constructor, creates all internal lists.
|
Email(javax.mail.internet.MimeMessage mimeMessage)
Constructor for
MimeMessage . |
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 . |
void |
addEmbeddedImage(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. |
void |
addEmbeddedImage(String name,
DataSource imagedata)
Overloaded method which sets an embedded image on account of name and
DataSource . |
void |
addHeader(String name,
Object value)
Adds a header to the
headers list. |
void |
addRecipient(String name,
String address,
javax.mail.Message.RecipientType type)
Adds a new
Recipient to the list on account of name, address and recipient type (eg. |
List<AttachmentResource> |
getAttachments()
Bean getter for
attachments as unmodifiable list. |
List<AttachmentResource> |
getEmbeddedImages()
Bean getter for
embeddedImages as unmodifiable list. |
Recipient |
getFromRecipient()
Bean getter for
fromRecipient . |
Map<String,String> |
getHeaders()
Bean getter for
headers as unmodifiable map. |
List<Recipient> |
getRecipients()
Bean getter for
recipients as unmodifiable list. |
Recipient |
getReplyToRecipient()
Bean getter for
replyToRecipient . |
String |
getSubject()
Bean getter for
subject . |
String |
getText()
Bean getter for
text . |
String |
getTextHTML()
Bean getter for
textHTML . |
void |
setFromAddress(String name,
String fromAddress)
Sets the sender address.
|
void |
setReplyToAddress(String name,
String replyToAddress)
Sets the reply-to address (optional).
|
void |
setSubject(String subject)
Bean setters for
subject . |
void |
setText(String text)
Bean setters for
text . |
void |
setTextHTML(String textHTML)
Bean setters for
textHTML . |
public Email()
public Email(javax.mail.internet.MimeMessage mimeMessage)
MimeMessage
.mimeMessage
- The MimeMessage from which to create the email.public void setFromAddress(String name, String fromAddress)
name
- The sender's name.fromAddress
- The sender's email address.public void setReplyToAddress(String name, String replyToAddress)
name
- The replied-to-receiver name.replyToAddress
- The replied-to-receiver email address.public void addRecipient(String name, String address, javax.mail.Message.RecipientType type)
Recipient
to the list on account of name, address and recipient type (eg. Message.RecipientType.CC
).name
- The name of the recipient.address
- The emailadres of the recipient.type
- The type of receiver (eg. Message.RecipientType.CC
).recipients
,
Recipient
,
Message.RecipientType
public void addEmbeddedImage(String name, byte[] data, String mimetype)
DataSource
with the given byte
data. Then delegates to 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
,
addEmbeddedImage(String, DataSource)
public void addEmbeddedImage(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 void 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.public Recipient getFromRecipient()
fromRecipient
.public Recipient getReplyToRecipient()
replyToRecipient
.public List<AttachmentResource> getAttachments()
attachments
as unmodifiable list.public List<AttachmentResource> getEmbeddedImages()
embeddedImages
as unmodifiable list.public List<Recipient> getRecipients()
recipients
as unmodifiable list.Copyright © 2016. All rights reserved.