Interface MessageBuilder
-
- All Known Implementing Classes:
SimpleMessageBuilder
@ProviderType public interface MessageBuilderBuilder for MIME messages.- See Also:
MimeMessage
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @NotNull MessageBuilderattachment(byte @NotNull [] content, @NotNull String type, @NotNull String filename)Attaches the given content to the message.@NotNull MessageBuilderattachment(byte @NotNull [] content, @NotNull String type, @NotNull String filename, @Nullable Collection<jakarta.mail.Header> headers)Attaches the given content with headers to the message.@NotNull MessageBuilderbcc(@NotNull jakarta.mail.internet.InternetAddress bcc)Adds the given address to the list of blind carbon copy (bcc) recipients.@NotNull MessageBuilderbcc(@NotNull jakarta.mail.internet.InternetAddress[] addresses)Adds the given addresses to the list of blind carbon copy (bcc) recipients.@NotNull MessageBuilderbcc(@NotNull String address)Creates a newInternetAddressfrom given address and adds it to the list of blind carbon copy (bcc) recipients.@NotNull MessageBuilderbcc(@NotNull String[] addresses)Creates newInternetAddresses from given addresses and adds them to the list of blind carbon copy (bcc) recipients.@NotNull MessageBuilderbcc(@NotNull String address, String name)Creates a newInternetAddressfrom given address and name and adds it to the list of blind carbon copy (bcc) recipients.@NotNull MessageBuilderbcc(@NotNull Collection<String> addresses)Creates newInternetAddresses from given addresses and adds them to the list of blind carbon copy (bcc) recipients.@NotNull jakarta.mail.internet.MimeMessagebuild()Builds the MIME message with the given input.@NotNull MessageBuildercc(@NotNull jakarta.mail.internet.InternetAddress cc)Adds the given address to the list of carbon copy (cc) recipients.@NotNull MessageBuildercc(@NotNull jakarta.mail.internet.InternetAddress[] addresses)Adds the given addresses to the list of carbon copy (cc) recipients.@NotNull MessageBuildercc(@NotNull String address)Creates a newInternetAddressfrom given address and adds it to the list of carbon copy (cc) recipients.@NotNull MessageBuildercc(@NotNull String[] addresses)Creates newInternetAddresses from given addresses and adds them to the list of carbon copy (cc) recipients.@NotNull MessageBuildercc(@NotNull String address, @NotNull String name)Creates a newInternetAddressfrom given address and name and adds it to the list of carbon copy (cc) recipients.@NotNull MessageBuildercc(@NotNull Collection<String> addresses)Creates newInternetAddresses from given addresses and adds them to the list of carbon copy (cc) recipients.@NotNull MessageBuilderfrom(@NotNull jakarta.mail.internet.InternetAddress from)Sets the given address for the RFC 822Fromheader field.@NotNull MessageBuilderfrom(@NotNull String address)Creates a newInternetAddressfrom given address and sets it for the RFC 822Fromheader field.@NotNull MessageBuilderfrom(@NotNull String address, @NotNull String name)Creates a newInternetAddressfrom given address and name and sets it for the RFC 822Fromheader field.@NotNull MessageBuilderheader(@NotNull String name, @Nullable String value)Creates a new header from given name and value and adds it to the list of headers.@NotNull MessageBuilderheaders(@NotNull Collection<jakarta.mail.Header> headers)Adds the given headers to the list of headers.@NotNull MessageBuilderhtml(@NotNull String html)Sets the HTML content.@NotNull MessageBuilderinline(byte @NotNull [] content, @NotNull String type, @NotNull String cid)Inlines the given content into the message.@NotNull MessageBuilderinline(byte @NotNull [] content, @NotNull String type, @NotNull String cid, @Nullable Collection<jakarta.mail.Header> headers)Inlines the given content with headers into the message.@NotNull MessageBuilderreplyTo(@NotNull jakarta.mail.internet.InternetAddress replyTo)Adds the given address to the list of addresses for the RFC 822Reply-Toheader field.@NotNull MessageBuilderreplyTo(@NotNull jakarta.mail.internet.InternetAddress[] addresses)Adds the given addresses to the list of addresses for the RFC 822Reply-Toheader field.@NotNull MessageBuilderreplyTo(@NotNull String address)Creates a newInternetAddressfrom given address and adds it to the list of addresses for the RFC 822Reply-Toheader field.@NotNull MessageBuilderreplyTo(@NotNull String[] addresses)Creates newInternetAddresses from given addresses and adds them to the list of addresses for the RFC 822Reply-Toheader field.@NotNull MessageBuilderreplyTo(@NotNull String address, String name)Creates a newInternetAddressfrom given address and name and adds it to the list of addresses for the RFC 822Reply-Toheader field.@NotNull MessageBuilderreplyTo(@NotNull Collection<String> addresses)Creates newInternetAddresses from given addresses and adds them to the list of addresses for the RFC 822Reply-Toheader field.@NotNull MessageBuildersubject(@NotNull String subject)Sets the given subject into theSubjectheader field.@NotNull MessageBuildertext(@NotNull String text)Sets the plain text content.@NotNull MessageBuilderto(@NotNull jakarta.mail.internet.InternetAddress to)Adds the given address to the list of primary (to) recipients.@NotNull MessageBuilderto(@NotNull jakarta.mail.internet.InternetAddress[] addresses)Adds the given addresses to the list of primary (to) recipients.@NotNull MessageBuilderto(@NotNull String address)Creates a newInternetAddressfrom given address and adds it to the list of primary (to) recipients.@NotNull MessageBuilderto(@NotNull String[] addresses)Creates newInternetAddresses from given addresses and adds them to the list of primary (to) recipients.@NotNull MessageBuilderto(@NotNull String address, @NotNull String name)Creates a newInternetAddressfrom given address and name and adds it to the list of primary (to) recipients.@NotNull MessageBuilderto(@NotNull Collection<String> addresses)Creates newInternetAddresses from given addresses and adds them to the list of primary (to) recipients.
-
-
-
Method Detail
-
header
@NotNull @NotNull MessageBuilder header(@NotNull @NotNull String name, @Nullable @Nullable String value)
Creates a new header from given name and value and adds it to the list of headers.- Parameters:
name- the name of the headervalue- the value of the header- Returns:
- the message builder
- See Also:
Header,InternetHeaders
-
headers
@NotNull @NotNull MessageBuilder headers(@NotNull @NotNull Collection<jakarta.mail.Header> headers)
Adds the given headers to the list of headers.- Parameters:
headers- the headers to add- Returns:
- the message builder
- See Also:
Header,InternetHeaders
-
from
@NotNull @NotNull MessageBuilder from(@NotNull @NotNull jakarta.mail.internet.InternetAddress from)
Sets the given address for the RFC 822Fromheader field.- Parameters:
from- the address- Returns:
- the message builder
- See Also:
MimeMessage.setFrom(Address)
-
from
@NotNull @NotNull MessageBuilder from(@NotNull @NotNull String address) throws jakarta.mail.internet.AddressException
Creates a newInternetAddressfrom given address and sets it for the RFC 822Fromheader field.- Parameters:
address- the address- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setFrom(Address)
-
from
@NotNull @NotNull MessageBuilder from(@NotNull @NotNull String address, @NotNull @NotNull String name) throws jakarta.mail.internet.AddressException
Creates a newInternetAddressfrom given address and name and sets it for the RFC 822Fromheader field.- Parameters:
address- the addressname- the (personal) name- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setFrom(Address)
-
to
@NotNull @NotNull MessageBuilder to(@NotNull @NotNull jakarta.mail.internet.InternetAddress to)
Adds the given address to the list of primary (to) recipients.- Parameters:
to- the address- Returns:
- the message builder
- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.TO
-
to
@NotNull @NotNull MessageBuilder to(@NotNull @NotNull String address) throws jakarta.mail.internet.AddressException
Creates a newInternetAddressfrom given address and adds it to the list of primary (to) recipients.- Parameters:
address- the address- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.TO
-
to
@NotNull @NotNull MessageBuilder to(@NotNull @NotNull String address, @NotNull @NotNull String name) throws jakarta.mail.internet.AddressException
Creates a newInternetAddressfrom given address and name and adds it to the list of primary (to) recipients.- Parameters:
address- the addressname- the (personal) name- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.TO
-
to
@NotNull @NotNull MessageBuilder to(@NotNull @NotNull jakarta.mail.internet.InternetAddress[] addresses)
Adds the given addresses to the list of primary (to) recipients.- Parameters:
addresses- the addresses- Returns:
- the message builder
- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.TO
-
to
@NotNull @NotNull MessageBuilder to(@NotNull @NotNull String[] addresses) throws jakarta.mail.internet.AddressException
Creates newInternetAddresses from given addresses and adds them to the list of primary (to) recipients.- Parameters:
addresses- the addresses- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address strings fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.TO
-
to
@NotNull @NotNull MessageBuilder to(@NotNull @NotNull Collection<String> addresses) throws jakarta.mail.internet.AddressException
Creates newInternetAddresses from given addresses and adds them to the list of primary (to) recipients.- Parameters:
addresses- the addresses- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address strings fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.TO
-
cc
@NotNull @NotNull MessageBuilder cc(@NotNull @NotNull jakarta.mail.internet.InternetAddress cc)
Adds the given address to the list of carbon copy (cc) recipients.- Parameters:
cc- the address- Returns:
- the message builder
- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.CC
-
cc
@NotNull @NotNull MessageBuilder cc(@NotNull @NotNull String address) throws jakarta.mail.internet.AddressException
Creates a newInternetAddressfrom given address and adds it to the list of carbon copy (cc) recipients.- Parameters:
address- the address- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.CC
-
cc
@NotNull @NotNull MessageBuilder cc(@NotNull @NotNull String address, @NotNull @NotNull String name) throws jakarta.mail.internet.AddressException
Creates a newInternetAddressfrom given address and name and adds it to the list of carbon copy (cc) recipients.- Parameters:
address- the addressname- the (personal) name- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.CC
-
cc
@NotNull @NotNull MessageBuilder cc(@NotNull @NotNull jakarta.mail.internet.InternetAddress[] addresses)
Adds the given addresses to the list of carbon copy (cc) recipients.- Parameters:
addresses- the addresses- Returns:
- the message builder
- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.CC
-
cc
@NotNull @NotNull MessageBuilder cc(@NotNull @NotNull String[] addresses) throws jakarta.mail.internet.AddressException
Creates newInternetAddresses from given addresses and adds them to the list of carbon copy (cc) recipients.- Parameters:
addresses- the addresses- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address strings fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.CC
-
cc
@NotNull @NotNull MessageBuilder cc(@NotNull @NotNull Collection<String> addresses) throws jakarta.mail.internet.AddressException
Creates newInternetAddresses from given addresses and adds them to the list of carbon copy (cc) recipients.- Parameters:
addresses- the addresses- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address strings fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.CC
-
bcc
@NotNull @NotNull MessageBuilder bcc(@NotNull @NotNull jakarta.mail.internet.InternetAddress bcc)
Adds the given address to the list of blind carbon copy (bcc) recipients.- Parameters:
bcc- the address- Returns:
- the message builder
- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.BCC
-
bcc
@NotNull @NotNull MessageBuilder bcc(@NotNull @NotNull String address) throws jakarta.mail.internet.AddressException
Creates a newInternetAddressfrom given address and adds it to the list of blind carbon copy (bcc) recipients.- Parameters:
address- the address- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.BCC
-
bcc
@NotNull @NotNull MessageBuilder bcc(@NotNull @NotNull String address, String name) throws jakarta.mail.internet.AddressException
Creates a newInternetAddressfrom given address and name and adds it to the list of blind carbon copy (bcc) recipients.- Parameters:
address- the addressname- the (personal) name- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.BCC
-
bcc
@NotNull @NotNull MessageBuilder bcc(@NotNull @NotNull jakarta.mail.internet.InternetAddress[] addresses)
Adds the given addresses to the list of blind carbon copy (bcc) recipients.- Parameters:
addresses- the addresses- Returns:
- the message builder
- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.BCC
-
bcc
@NotNull @NotNull MessageBuilder bcc(@NotNull @NotNull String[] addresses) throws jakarta.mail.internet.AddressException
Creates newInternetAddresses from given addresses and adds them to the list of blind carbon copy (bcc) recipients.- Parameters:
addresses- the addresses- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address strings fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.BCC
-
bcc
@NotNull @NotNull MessageBuilder bcc(@NotNull @NotNull Collection<String> addresses) throws jakarta.mail.internet.AddressException
Creates newInternetAddresses from given addresses and adds them to the list of blind carbon copy (bcc) recipients.- Parameters:
addresses- the addresses- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address strings fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.BCC
-
replyTo
@NotNull @NotNull MessageBuilder replyTo(@NotNull @NotNull jakarta.mail.internet.InternetAddress replyTo)
Adds the given address to the list of addresses for the RFC 822Reply-Toheader field.- Parameters:
replyTo- the address- Returns:
- the message builder
- See Also:
MimeMessage.setReplyTo(Address[])
-
replyTo
@NotNull @NotNull MessageBuilder replyTo(@NotNull @NotNull String address) throws jakarta.mail.internet.AddressException
Creates a newInternetAddressfrom given address and adds it to the list of addresses for the RFC 822Reply-Toheader field.- Parameters:
address- the address- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setReplyTo(Address[])
-
replyTo
@NotNull @NotNull MessageBuilder replyTo(@NotNull @NotNull String address, String name) throws jakarta.mail.internet.AddressException
Creates a newInternetAddressfrom given address and name and adds it to the list of addresses for the RFC 822Reply-Toheader field.- Parameters:
address- the addressname- the (personal) name- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setReplyTo(Address[])
-
replyTo
@NotNull @NotNull MessageBuilder replyTo(@NotNull @NotNull jakarta.mail.internet.InternetAddress[] addresses)
Adds the given addresses to the list of addresses for the RFC 822Reply-Toheader field.- Parameters:
addresses- the addresses- Returns:
- the message builder
- See Also:
MimeMessage.setReplyTo(Address[])
-
replyTo
@NotNull @NotNull MessageBuilder replyTo(@NotNull @NotNull String[] addresses) throws jakarta.mail.internet.AddressException
Creates newInternetAddresses from given addresses and adds them to the list of addresses for the RFC 822Reply-Toheader field.- Parameters:
addresses- the addresses- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address strings fails- See Also:
MimeMessage.setReplyTo(Address[])
-
replyTo
@NotNull @NotNull MessageBuilder replyTo(@NotNull @NotNull Collection<String> addresses) throws jakarta.mail.internet.AddressException
Creates newInternetAddresses from given addresses and adds them to the list of addresses for the RFC 822Reply-Toheader field.- Parameters:
addresses- the addresses- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address strings fails- See Also:
MimeMessage.setReplyTo(Address[])
-
subject
@NotNull @NotNull MessageBuilder subject(@NotNull @NotNull String subject)
Sets the given subject into theSubjectheader field.- Parameters:
subject- the subject of the message- Returns:
- the message builder
- See Also:
MimeMessage.setSubject(String)
-
text
@NotNull @NotNull MessageBuilder text(@NotNull @NotNull String text)
Sets the plain text content.- Parameters:
text- the plain text content- Returns:
- the message builder
- See Also:
MimeMessage.setText(String, String),MimeBodyPart.setContent(Object, String)
-
html
@NotNull @NotNull MessageBuilder html(@NotNull @NotNull String html)
Sets the HTML content.- Parameters:
html- the HTML content- Returns:
- the message builder
- See Also:
MimeBodyPart.setContent(Object, String)
-
attachment
@NotNull @NotNull MessageBuilder attachment(byte @NotNull [] content, @NotNull @NotNull String type, @NotNull @NotNull String filename)
Attaches the given content to the message.- Parameters:
content- the content to attachtype- the type of the content (content/media/MIME type)filename- the filename of the attachment- Returns:
- the message builder
- See Also:
Part.ATTACHMENT
-
attachment
@NotNull @NotNull MessageBuilder attachment(byte @NotNull [] content, @NotNull @NotNull String type, @NotNull @NotNull String filename, @Nullable @Nullable Collection<jakarta.mail.Header> headers)
Attaches the given content with headers to the message.- Parameters:
content- the content to attachtype- the type of the content (content/media/MIME type)filename- the filename of the attachmentheaders- the headers for the content- Returns:
- the message builder
- See Also:
Part.ATTACHMENT
-
inline
@NotNull @NotNull MessageBuilder inline(byte @NotNull [] content, @NotNull @NotNull String type, @NotNull @NotNull String cid)
Inlines the given content into the message.- Parameters:
content- the content to inlinetype- the type of the content (content/media/MIME type)cid- the content identifier (Content-ID)- Returns:
- the message builder
- See Also:
Part.INLINE
-
inline
@NotNull @NotNull MessageBuilder inline(byte @NotNull [] content, @NotNull @NotNull String type, @NotNull @NotNull String cid, @Nullable @Nullable Collection<jakarta.mail.Header> headers)
Inlines the given content with headers into the message.- Parameters:
content- the content to inlinetype- the type of the content (content/media/MIME type)cid- the content identifier (Content-ID)headers- the headers for the content- Returns:
- the message builder
- See Also:
Part.INLINE
-
build
@NotNull @NotNull jakarta.mail.internet.MimeMessage build() throws jakarta.mail.MessagingExceptionBuilds the MIME message with the given input.- Returns:
- the built message
- Throws:
jakarta.mail.MessagingException- if building message fails
-
-