- All Implemented Interfaces:
MailMessage
- Author:
- Besmir Beqiri
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttachment(File file) Adds aFileas an attachment to this message.voidaddAttachment(File file, String cid) Adds aFileas an attachment to this message with the given content ID.voidaddAttachment(File file, String contentType, String encoding) Adds aFileas an attachment to this message with the given content type and encoding.voidAdd these addresses to the existing "Bcc" attribute.voidAdd these addresses to the existing "Cc" attribute.voidAdd these addresses to the existing "From" attribute.voidAdd these addresses to the existing "To" attribute.org.eclipse.collections.api.list.ImmutableList<String> Get all the recipients of this message.org.eclipse.collections.api.list.ImmutableList<String> getBcc()Return the "Bcc" attribute addresses.org.eclipse.collections.api.list.ImmutableList<String> getCc()Return the "Cc" attribute addresses.org.eclipse.collections.api.list.ImmutableList<String> getFrom()Returns the "From" attribute addresses.Get the date this message was received.org.eclipse.collections.api.list.ImmutableList<String> Get the addresses to which replies should be directed.Get the date this message was sent.Get the subject of this message.org.eclipse.collections.api.list.ImmutableList<String> getTo()Returns the "To" attribute addresses.Save any changes made to this message into the message-store when the containing folder is closed, if the message is contained in a folder.send()Send a message.Send the message to the specified addresses, ignoring any recipients specified in the message itself.voidSet the "Bcc" attribute addresses in this message.voidSet the "Cc" attribute addresses in this message.voidSet the "From" attribute address in this message.voidA convenience method that sets the given String as this part's content with a MIME type of "text/html".voidsetReplyTo(org.eclipse.collections.api.list.ImmutableList<String> addresses) Set the addresses to which replies should be directed.voidsetSentDate(Instant instant) Set the sent date of this message.voidsetSubject(String subject) Set the subject of this message.voidA convenience method that sets the given String as this part's content with a MIME type of "text/plain".voidSet the "To" attribute address in this message.voidSet the "To" attribute addresses in this message.
-
Method Details
-
getFrom
Description copied from interface:MailMessageReturns the "From" attribute addresses. The "From" attribute contains the identity of the person(s) who wished this message to be sent.This method returns
nullif this attribute is not present in this message. Returns an empty array if this attribute is present, but contains no addresses.- Specified by:
getFromin interfaceMailMessage- Returns:
- immutable list of Strings containing the addresses of the sender
-
setFrom
Description copied from interface:MailMessageSet the "From" attribute address in this message.- Specified by:
setFromin interfaceMailMessage- Parameters:
address- the sender address
-
addFrom
Description copied from interface:MailMessageAdd these addresses to the existing "From" attribute.- Specified by:
addFromin interfaceMailMessage- Parameters:
addresses- the sender addresses
-
getTo
Description copied from interface:MailMessageReturns the "To" attribute addresses. The "To" attribute contains the primary recipients of this message.This method returns
nullif this attribute is not present in this message. Returns an empty array if this attribute is present, but contains no addresses.- Specified by:
getToin interfaceMailMessage- Returns:
- immutable list of Strings containing the addresses of the primary recipients
-
setTo
Description copied from interface:MailMessageSet the "To" attribute address in this message.- Specified by:
setToin interfaceMailMessage- Parameters:
address- the primary recipient address
-
setTo
Description copied from interface:MailMessageSet the "To" attribute addresses in this message.- Specified by:
setToin interfaceMailMessage- Parameters:
addresses- the primary recipient addresses
-
addTo
Description copied from interface:MailMessageAdd these addresses to the existing "To" attribute.- Specified by:
addToin interfaceMailMessage- Parameters:
addresses- the primary recipient addresses
-
getCc
Description copied from interface:MailMessageReturn the "Cc" attribute addresses. The "Cc" attribute contains secondary recipients of this message.This method returns
nullif this attribute is not present in this message. Returns an empty array if this attribute is present, but contains no addresses.- Specified by:
getCcin interfaceMailMessage- Returns:
- immutable list of Strings containing the addresses of the secondary recipients
-
setCc
Description copied from interface:MailMessageSet the "Cc" attribute addresses in this message.- Specified by:
setCcin interfaceMailMessage- Parameters:
addresses- the secondary recipient addresses
-
addCc
Description copied from interface:MailMessageAdd these addresses to the existing "Cc" attribute.- Specified by:
addCcin interfaceMailMessage- Parameters:
addresses- the secondary recipient addresses
-
getBcc
Description copied from interface:MailMessageReturn the "Bcc" attribute addresses. The "Bcc" attribute contains tertiary recipients of this message.This method returns
nullif this attribute is not present in this message. Returns an empty array if this attribute is present, but contains no addresses.- Specified by:
getBccin interfaceMailMessage- Returns:
- immutable list of Strings containing the addresses of the tertiary recipients
-
setBcc
Description copied from interface:MailMessageSet the "Bcc" attribute addresses in this message.- Specified by:
setBccin interfaceMailMessage- Parameters:
addresses- the tertiary recipient addresses
-
addBcc
Description copied from interface:MailMessageAdd these addresses to the existing "Bcc" attribute.- Specified by:
addBccin interfaceMailMessage- Parameters:
addresses- the tertiary recipient addresses
-
getAllRecipients
Description copied from interface:MailMessageGet all the recipients of this message. This method returnsnullif the corresponding header is not present. Returns an empty array if the header is present, but contains no addresses.- Specified by:
getAllRecipientsin interfaceMailMessage- Returns:
- all the recipients of this message
-
getReplyTo
Description copied from interface:MailMessageGet the addresses to which replies should be directed. This will usually be the sender of the message, but some messages may direct replies to a different address.The default implementation simply calls the
getFrommethod.This method returns
nullif the corresponding header is not present. Returns an empty array if the header is present, but contains no addresses.- Specified by:
getReplyToin interfaceMailMessage- Returns:
- addresses to which replies should be directed
- See Also:
-
setReplyTo
Description copied from interface:MailMessageSet the addresses to which replies should be directed. (Normally only a single address will be specified.) Not all message types allow this to be specified separately from the sender of the message.The default implementation provided here just throws the MethodNotSupportedException.
- Specified by:
setReplyToin interfaceMailMessage- Parameters:
addresses- addresses to which replies should be directed
-
getSubject
Description copied from interface:MailMessageGet the subject of this message.- Specified by:
getSubjectin interfaceMailMessage- Returns:
- the subject string
-
setSubject
Description copied from interface:MailMessageSet the subject of this message.- Specified by:
setSubjectin interfaceMailMessage- Parameters:
subject- the subject string
-
setText
Description copied from interface:MailMessageA convenience method that sets the given String as this part's content with a MIME type of "text/plain".- Specified by:
setTextin interfaceMailMessage- Parameters:
text- the text that is the message's content
-
setHtml
Description copied from interface:MailMessageA convenience method that sets the given String as this part's content with a MIME type of "text/html".- Specified by:
setHtmlin interfaceMailMessage- Parameters:
htmlText- the html content that is the message's content
-
addAttachment
Description copied from interface:MailMessageAdds aFileas an attachment to this message.- Specified by:
addAttachmentin interfaceMailMessage- Parameters:
file- the file to attach
-
addAttachment
Description copied from interface:MailMessageAdds aFileas an attachment to this message with the given content ID.- Specified by:
addAttachmentin interfaceMailMessage- Parameters:
file- the file to attachcid- the "Content-ID" of the attachment
-
addAttachment
Description copied from interface:MailMessageAdds aFileas an attachment to this message with the given content type and encoding.- Specified by:
addAttachmentin interfaceMailMessage- Parameters:
file- the file to attachcontentType- the content type of the fileencoding- the encoding of the file
-
getSentDate
Description copied from interface:MailMessageGet the date this message was sent.- Specified by:
getSentDatein interfaceMailMessage- Returns:
- the instant this message was sent
-
setSentDate
Description copied from interface:MailMessageSet the sent date of this message.- Specified by:
setSentDatein interfaceMailMessage- Parameters:
instant- the instant this message was sent
-
getReceivedDate
Description copied from interface:MailMessageGet the date this message was received.- Specified by:
getReceivedDatein interfaceMailMessage- Returns:
- the instant this message was received
-
saveChanges
Description copied from interface:MailMessageSave any changes made to this message into the message-store when the containing folder is closed, if the message is contained in a folder. Update any header fields to be consistent with the changed message contents. If any part of a message's headers or contents are changed, this method must be called to ensure that those changes are permanent. If this method is not called, any such modifications may or may not be saved, depending on the message store and folder implementation.Messages obtained from folders opened READ_ONLY should not be modified and
saveChangesshould not be called on such messages.- Specified by:
saveChangesin interfaceMailMessage- Returns:
- a
CompletableFuturethat completes when the changes are saved
-
send
Description copied from interface:MailMessageSend a message. The message will be sent to all recipient addresses specified in the message (as returned from the methodMailMessage.getAllRecipients()), using message transports appropriate to each address. Thesendmethod calls thesaveChangesmethod on the message before sending it.In typical usage, a
MailExceptionreflects an error detected by the server. The details of theMailExceptionwill usually contain the error message from the server (such as an SMTP error message). An address may be detected as invalid for a variety of reasons - the address may not exist, the address may have invalid syntax, the address may have exceeded its quota, etc.- Specified by:
sendin interfaceMailMessage- Returns:
- a
CompletableFuturethat completes when the message is sent - See Also:
-
send
public CompletableFuture<Void> send(org.eclipse.collections.api.list.ImmutableList<String> addresses) Description copied from interface:MailMessageSend the message to the specified addresses, ignoring any recipients specified in the message itself. Thesendmethod calls thesaveChangesmethod on the message before sending it.- Specified by:
sendin interfaceMailMessage- Parameters:
addresses- the addresses to which to send the message- Returns:
- a
CompletableFuturethat completes when the message is sent - See Also:
-