Package com.axelor.mail
Class MailBuilder
java.lang.Object
com.axelor.mail.MailBuilder
The
MailBuilder defines fluent API to build MimeMessage and if required can send
the built message directly.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAttach a file referenced by the given link.jakarta.mail.internet.MimeMessagebuild()Build a newMimeMessageinstance from the provided details.jakarta.mail.internet.MimeMessageBuild a newMimeMessageinstance from the provided details.Attach a file as inline content.jakarta.mail.internet.MimeMessagesend()Send the message.jakarta.mail.internet.MimeMessageSend the message with given send date.
-
Constructor Details
-
MailBuilder
public MailBuilder(jakarta.mail.Session session)
-
-
Method Details
-
subject
-
to
-
cc
-
bcc
-
replyTo
-
from
-
sender
-
header
-
text
-
html
-
attach
-
attach
Attach a file referenced by the given link.If you want to reference the attachment as inline image, provide content id wrapped by angle brackets and refer the image with content id without angle brackets. For example:
builder.html("<img src='cid:logo.png'>").attach("logo.png", "/path/to/logo.png", "<logo.png>").send();- Parameters:
name- attachment file namelink- attachment file link (url or file path)cid- content id- Returns:
- this
-
inline
Attach a file as inline content.- Parameters:
name- attachment file namelink- attachment file link (url or file path)- Returns:
- this
-
build
public jakarta.mail.internet.MimeMessage build() throws jakarta.mail.MessagingException, IOExceptionBuild a newMimeMessageinstance from the provided details.- Returns:
- an instance of
MimeMessage - Throws:
IOException- generally thrown byDataHandlerjakarta.mail.MessagingException- for failure
-
build
public jakarta.mail.internet.MimeMessage build(String messageId) throws jakarta.mail.MessagingException, IOException Build a newMimeMessageinstance from the provided details.- Parameters:
messageId- custom "Message-ID" to use, null to use auto-generated- Returns:
- an instance of
MimeMessage - Throws:
IOException- generally thrown byDataHandlerjakarta.mail.MessagingException- for failure
-
send
public jakarta.mail.internet.MimeMessage send(Date date) throws jakarta.mail.MessagingException, IOException Send the message with given send date.- Parameters:
date- send date, can be null- Returns:
- sent
MimeMessage - Throws:
IOException- generally thrown byDataHandlerjakarta.mail.MessagingException- for failure
-
send
Send the message.- Returns:
- sent
MimeMessage - Throws:
IOException- generally thrown byDataHandlerjakarta.mail.MessagingException- for failure
-