Fluent builder for composing a single outbound email and queuing it for delivery, obtained in JS from applications.email.emailBuilder(). A caller sets the recipient (either by address or by profile), the sender details, the subject and body, and optionally one or more attachments, then calls build() to save the composed message as an EmailItem and queue it for sending. The recipient and sender can be resolved automatically from an address if not set explicitly.

Group: Builders


Methods

recipientAddress(String recipientAddress) · recipient(ProfileBean pb) · recipient(Profile profile) · fromAddress(String fromAddress) · replyToAddress(String replyToAddress) · toList(List toList) · ccList(List ccList) · bccList(List bccList) · subject(String subject) · text(String text) · html(String html) · inReplyTo(String inReplyTo) · references(String references) · addAttachement(String fileName, String fileHash, String contentType, String disposition) · addAttachement(String fileName, String fileHash, String contentType) · lead(Lead lead) · build()

recipientAddress(String recipientAddress)

Returns: EmailItemBuilder

Sets the recipient's email address. If no recipient profile is set explicitly, this address is used to look up a matching user or organisation within the account when the email is built.

ParameterDescription
recipientAddressthe recipient's email address

recipient(ProfileBean pb)

Returns: EmailItemBuilder

Sets the recipient directly from a profile bean, unwrapping it to the underlying Profile entity.

ParameterDescription
pbthe bean wrapping the recipient's profile

recipient(Profile profile)

Returns: EmailItemBuilder

Sets the recipient directly from a profile entity.

ParameterDescription
profilethe recipient's profile

fromAddress(String fromAddress)

Returns: EmailItemBuilder

Sets the From address of the email. If not set, and a sender profile has been resolved, the sender's email address is used instead.

ParameterDescription
fromAddressthe sending address

replyToAddress(String replyToAddress)

Returns: EmailItemBuilder

Sets the Reply-To address of the email. If not set, the From address is used instead.

ParameterDescription
replyToAddressthe address replies should be sent to

toList(List toList)

Returns: EmailItemBuilder

Appends one or more To recipients, given as MailboxAddress or String values, to the email's To list. Can be called more than once to add further recipients.

ParameterDescription
toListthe recipients to add to the To list

ccList(List ccList)

Returns: EmailItemBuilder

Appends one or more Cc recipients, given as MailboxAddress or String values, to the email's Cc list. Can be called more than once to add further recipients.

ParameterDescription
ccListthe recipients to add to the Cc list

bccList(List bccList)

Returns: EmailItemBuilder

Appends one or more Bcc recipients, given as MailboxAddress or String values, to the email's Bcc list. Can be called more than once to add further recipients.

ParameterDescription
bccListthe recipients to add to the Bcc list

subject(String subject)

Returns: EmailItemBuilder

Sets the subject line of the email.

ParameterDescription
subjectthe email subject

text(String text)

Returns: EmailItemBuilder

Sets the plain text body of the email. If left unset and an HTML body is provided, the plain text body is derived from it automatically when the email is built.

ParameterDescription
textthe plain text body

html(String html)

Returns: EmailItemBuilder

Sets the HTML body of the email. If left unset and a plain text body is provided, the HTML body defaults to that text when the email is built.

ParameterDescription
htmlthe HTML body

inReplyTo(String inReplyTo)

Returns: EmailItemBuilder

Sets the In-Reply-To header, used to thread this email as a reply to an earlier message.

ParameterDescription
inReplyTothe message id of the email this is in reply to

references(String references)

Returns: EmailItemBuilder

Sets the References header, used to thread this email within a longer conversation.

ParameterDescription
referencesthe References header value

addAttachement(String fileName, String fileHash, String contentType, String disposition)

Returns: EmailItemBuilder

Adds an attachment to the email, referencing content already stored in the VFS by its hash.

ParameterDescription
fileNamethe name of the attached file
fileHashthe hash used to locate the file's content in the VFS
contentTypethe file's content type
dispositionthe attachment disposition, eg inline or attachment. Defaults to attachment

addAttachement(String fileName, String fileHash, String contentType)

Returns: EmailItemBuilder

Adds an attachment to the email, referencing content already stored in the VFS by its hash, using the default attachment disposition.

ParameterDescription
fileNamethe name of the attached file
fileHashthe hash used to locate the file's content in the VFS
contentTypethe file's content type

lead(Lead lead)

Returns: EmailItemBuilder

Associates this email with a funnel lead, so its engagement (opens and click-throughs) can be tracked against the lead's EDM history.

ParameterDescription
leadthe lead to associate this email with

build()

Returns: EmailItem

Resolves the recipient and sender if not set explicitly, fills in a missing plain text or HTML body from the other, saves the composed message as an EmailItem, attaches any files added with addAttachement, links it to a lead if one was set, and queues it for sending. Opens and commits its own database session and transaction if none is already active.

To get full access to the Kademi Hub existing customers can login here, or new customers can register here.