@Component(value="cuba_EmailInfoBuilder")
@Scope(value="prototype")
public class EmailInfoBuilder
extends java.lang.Object
Use setters to provide parameters and then invoke the build method to obtain the EmailInfo instance.
Sample usage:
EmailInfo emailInfo = EmailInfoBuilder.create() .setAddresses(addresses) .setCaption("Email subject") .setBody("Some email body") .build();
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NAME |
Constructor and Description |
---|
EmailInfoBuilder()
INTERNAL
|
EmailInfoBuilder(java.lang.String addresses,
java.lang.String caption,
java.lang.String body)
INTERNAL
|
Modifier and Type | Method and Description |
---|---|
EmailInfoBuilder |
addAttachment(EmailAttachment attachment) |
EmailInfoBuilder |
addHeader(EmailHeader header) |
EmailInfoBuilder |
addTemplateParameter(java.lang.String name,
java.io.Serializable value) |
EmailInfo |
build() |
static EmailInfoBuilder |
create()
EmailInfo emailInfo = EmailInfo.create()
.setAddresses("john.doe@company.com,jane.roe@company.com")
.setCaption("Company news")
.setBody("Some content")
.build();
|
static EmailInfoBuilder |
create(java.lang.String addresses,
java.lang.String caption,
java.lang.String body)
EmailInfo emailInfo = EmailInfo.create("john.doe@company.com,jane.roe@company.com", "Company news", "Some content").build();
|
java.lang.String |
getAddresses() |
EmailAttachment[] |
getAttachments() |
java.lang.String |
getBcc() |
java.lang.String |
getBody() |
java.lang.String |
getBodyContentType() |
java.lang.String |
getCaption() |
java.lang.String |
getCc() |
java.lang.String |
getFrom() |
java.util.List<EmailHeader> |
getHeaders() |
java.util.Map<java.lang.String,java.io.Serializable> |
getTemplateParameters() |
java.lang.String |
getTemplatePath() |
boolean |
isSendInOneMessage() |
EmailInfoBuilder |
setAddresses(java.lang.String addresses) |
EmailInfoBuilder |
setAttachments(EmailAttachment... attachments) |
EmailInfoBuilder |
setBcc(java.lang.String bcc)
Result of this method call (i.e., setting addresses of the email BCC field) is ignored during the message creation if
isSendInOneMessage() returns false (default
behaviour), because, in this case, the message is generated for each of the recipients
separately. |
EmailInfoBuilder |
setBody(java.lang.String body) |
EmailInfoBuilder |
setBodyContentType(java.lang.String bodyContentType) |
EmailInfoBuilder |
setCaption(java.lang.String caption) |
EmailInfoBuilder |
setCc(java.lang.String cc)
Result of this method call (i.e., setting addresses of the email CC field) is ignored during the message creation if
isSendInOneMessage() returns false (default
behaviour), because, in this case, the message is generated for each of the recipients
separately. |
EmailInfoBuilder |
setFrom(java.lang.String from) |
EmailInfoBuilder |
setHeaders(java.util.List<EmailHeader> headers) |
EmailInfoBuilder |
setSendInOneMessage(boolean sendInOneMessage)
Flag
sendInOneMessage is for backward compatibility with previous CUBA versions. |
EmailInfoBuilder |
setTemplateParameters(java.util.Map<java.lang.String,java.io.Serializable> templateParameters) |
EmailInfoBuilder |
setTemplatePath(java.lang.String templatePath) |
public static final java.lang.String NAME
public EmailInfoBuilder(java.lang.String addresses, java.lang.String caption, java.lang.String body)
public EmailInfoBuilder()
public static EmailInfoBuilder create()
EmailInfo emailInfo = EmailInfo.create()
.setAddresses("john.doe@company.com,jane.roe@company.com")
.setCaption("Company news")
.setBody("Some content")
.build();
public static EmailInfoBuilder create(java.lang.String addresses, java.lang.String caption, java.lang.String body)
EmailInfo emailInfo = EmailInfo.create("john.doe@company.com,jane.roe@company.com", "Company news", "Some content").build();
addresses
- comma or semicolon separated list of addressescaption
- email subjectbody
- email bodypublic EmailInfoBuilder setAddresses(java.lang.String addresses)
addresses
- Recipient email addresses separated with "," or ";" symbol.public java.lang.String getAddresses()
public java.lang.String getCc()
public EmailInfoBuilder setCc(java.lang.String cc)
isSendInOneMessage()
returns false
(default
behaviour), because, in this case, the message is generated for each of the recipients
separately.public java.lang.String getBcc()
public EmailInfoBuilder setBcc(java.lang.String bcc)
isSendInOneMessage()
returns false
(default
behaviour), because, in this case, the message is generated for each of the recipients
separately.public boolean isSendInOneMessage()
public EmailInfoBuilder setSendInOneMessage(boolean sendInOneMessage)
sendInOneMessage
is for backward compatibility with previous CUBA versions.
If sendInOneMessage = true
then one message will be sent for all recipients and it will include CC and BCC.
Otherwise CC and BCC are ignored and multiple messages by the number of recipients in addresses will be sent.public java.lang.String getCaption()
public EmailInfoBuilder setCaption(java.lang.String caption)
caption
- email subjectpublic java.lang.String getFrom()
public EmailInfoBuilder setFrom(java.lang.String from)
from
- "from" address. If null, a default provided by cuba.email.fromAddress
app property is used.public java.lang.String getTemplatePath()
public EmailInfoBuilder setTemplatePath(java.lang.String templatePath)
templatePath
- path to a Freemarker template which is used to create the message body. The template
is loaded through Resources
in the core module.public java.util.Map<java.lang.String,java.io.Serializable> getTemplateParameters()
public EmailInfoBuilder setTemplateParameters(java.util.Map<java.lang.String,java.io.Serializable> templateParameters)
templateParameters
- map of parameters to be passed to the templatepublic EmailInfoBuilder addTemplateParameter(java.lang.String name, java.io.Serializable value)
public java.lang.String getBody()
public EmailInfoBuilder setBody(java.lang.String body)
body
- email bodypublic java.lang.String getBodyContentType()
public EmailInfoBuilder setBodyContentType(java.lang.String bodyContentType)
bodyContentType
- email body like "text/plain; charset=UTF-8" or "text/html; charset=UTF-8", etcpublic EmailAttachment[] getAttachments()
public EmailInfoBuilder setAttachments(EmailAttachment... attachments)
attachments
- email attachmentspublic EmailInfoBuilder addAttachment(EmailAttachment attachment)
public java.util.List<EmailHeader> getHeaders()
public EmailInfoBuilder setHeaders(java.util.List<EmailHeader> headers)
public EmailInfoBuilder addHeader(EmailHeader header)
public EmailInfo build()