Package cl.obcom.desktopfx.core
Interface MailSender
public interface MailSender
Builds a multi-part mail message and sends it to one or more recipients.
-
Method Summary
Modifier and TypeMethodDescriptionaddPart
(byte[] bytes) Adds a bytes part to the this mail sender.Adds a bytes part with type to this mail sender.Adds a bytes part with type and name to this mail sender.Adds a file part to this mail sender.Adds a file part with type to this mail sender.addRecipients
(String... recipients) Adds a list of recipient mail addresses to this mail sender.void
clear()
Clears the state of this mail sender and releases internal resources.void
send()
Builds the mail message and sends it to the specified recipients.setMessage
(String message) Sets the message body of this mail sender.setSubject
(String subject) Sets the message subject of this mail sender.
-
Method Details
-
clear
void clear()Clears the state of this mail sender and releases internal resources. -
addRecipients
Adds a list of recipient mail addresses to this mail sender. Each element in this list may contain one single mail address, or a comma separated list of mail addresses.- Parameters:
recipients
- list of recipient mail addresses to add.- Returns:
- this updated mail sender for method chaining.
- Throws:
IllegalArgumentException
- if a mail address is invalid.Exception
- if an unexpected error occurs.
-
setSubject
Sets the message subject of this mail sender.- Parameters:
subject
- the message subject of this mail sender.- Returns:
- this updated mail sender for method chaining.
- Throws:
NullPointerException
- ifsubject
isnull
.IllegalArgumentException
- ifsubject
is invalid.Exception
- if an unexpected error occurs.
-
setMessage
Sets the message body of this mail sender.- Parameters:
message
- the message body of this mail sender.- Returns:
- this updated mail sender for method chaining.
- Throws:
NullPointerException
- ifmessage
isnull
.IllegalArgumentException
- ifmessage
is invalid.Exception
- if an unexpected error occurs.
-
addPart
Adds a file part to this mail sender.- Parameters:
file
- the file part to add to this mail sender.- Returns:
- this updated mail sender for method chaining.
- Throws:
NullPointerException
- iffile
isnull
.IllegalArgumentException
- iffile
is invalid.Exception
- if an unexpected error occurs.
-
addPart
Adds a file part with type to this mail sender.- Parameters:
file
- the file part to add to this mail sender.type
- the content type of the suppliedfile
.- Returns:
- this updated mail sender for method chaining.
- Throws:
NullPointerException
- if an argument isnull
.IllegalArgumentException
- if an argument is invalid.Exception
- if an unexpected error occurs.
-
addPart
Adds a bytes part to the this mail sender.- Parameters:
bytes
- the bytes part to add to this mail sender.- Returns:
- this updated mail sender for method chaining.
- Throws:
NullPointerException
- ifbytes
isnull
.IllegalArgumentException
- ifbytes
is invalid.Exception
- if an unexpected error occurs.
-
addPart
Adds a bytes part with type to this mail sender.- Parameters:
bytes
- the bytes part to add to this mail sender.type
- the content type of the suppliedbytes
.- Returns:
- this updated mail sender for method chaining.
- Throws:
NullPointerException
- if an argument isnull
.IllegalArgumentException
- if an argument is invalid.Exception
- if an unexpected error occurs.
-
addPart
Adds a bytes part with type and name to this mail sender.- Parameters:
bytes
- the bytes part to add to this mail sender.type
- the content type of the suppliedbytes
.name
- the optional name of the suppliedbytes
.- Returns:
- this updated mail sender for method chaining.
- Throws:
NullPointerException
- if an argument isnull
.IllegalArgumentException
- if an argument is invalid.Exception
- if an unexpected error occurs.
-
send
Builds the mail message and sends it to the specified recipients.- Throws:
Exception
- if an unexpected error occurs.
-