Class MailMessageImpl

java.lang.Object
one.jpro.platform.mail.impl.MailMessageImpl
All Implemented Interfaces:
MailMessage

public class MailMessageImpl extends Object implements MailMessage
Mail message implementation.
Author:
Besmir Beqiri
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a File as an attachment to this message.
    void
    Adds a File as an attachment to this message with the given content ID.
    void
    addAttachment(File file, String contentType, String encoding)
    Adds a File as an attachment to this message with the given content type and encoding.
    void
    addBcc(org.eclipse.collections.api.list.ImmutableList<String> addresses)
    Add these addresses to the existing "Bcc" attribute.
    void
    addCc(org.eclipse.collections.api.list.ImmutableList<String> addresses)
    Add these addresses to the existing "Cc" attribute.
    void
    addFrom(org.eclipse.collections.api.list.ImmutableList<String> addresses)
    Add these addresses to the existing "From" attribute.
    void
    addTo(org.eclipse.collections.api.list.ImmutableList<String> addresses)
    Add 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>
    Return the "Bcc" attribute addresses.
    org.eclipse.collections.api.list.ImmutableList<String>
    Return the "Cc" attribute addresses.
    org.eclipse.collections.api.list.ImmutableList<String>
    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>
    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 a message.
    send(org.eclipse.collections.api.list.ImmutableList<String> addresses)
    Send the message to the specified addresses, ignoring any recipients specified in the message itself.
    void
    setBcc(org.eclipse.collections.api.list.ImmutableList<String> addresses)
    Set the "Bcc" attribute addresses in this message.
    void
    setCc(org.eclipse.collections.api.list.ImmutableList<String> addresses)
    Set the "Cc" attribute addresses in this message.
    void
    setFrom(String address)
    Set the "From" attribute address in this message.
    void
    setHtml(String htmlText)
    A convenience method that sets the given String as this part's content with a MIME type of "text/html".
    void
    setReplyTo(org.eclipse.collections.api.list.ImmutableList<String> addresses)
    Set the addresses to which replies should be directed.
    void
    Set the sent date of this message.
    void
    setSubject(String subject)
    Set the subject of this message.
    void
    A convenience method that sets the given String as this part's content with a MIME type of "text/plain".
    void
    setTo(String address)
    Set the "To" attribute address in this message.
    void
    setTo(org.eclipse.collections.api.list.ImmutableList<String> addresses)
    Set the "To" attribute addresses in this message.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getFrom

      public org.eclipse.collections.api.list.ImmutableList<String> getFrom()
      Description copied from interface: MailMessage
      Returns the "From" attribute addresses. The "From" attribute contains the identity of the person(s) who wished this message to be sent.

      This method returns null if this attribute is not present in this message. Returns an empty array if this attribute is present, but contains no addresses.

      Specified by:
      getFrom in interface MailMessage
      Returns:
      immutable list of Strings containing the addresses of the sender
    • setFrom

      public void setFrom(String address)
      Description copied from interface: MailMessage
      Set the "From" attribute address in this message.
      Specified by:
      setFrom in interface MailMessage
      Parameters:
      address - the sender address
    • addFrom

      public void addFrom(org.eclipse.collections.api.list.ImmutableList<String> addresses)
      Description copied from interface: MailMessage
      Add these addresses to the existing "From" attribute.
      Specified by:
      addFrom in interface MailMessage
      Parameters:
      addresses - the sender addresses
    • getTo

      public org.eclipse.collections.api.list.ImmutableList<String> getTo()
      Description copied from interface: MailMessage
      Returns the "To" attribute addresses. The "To" attribute contains the primary recipients of this message.

      This method returns null if this attribute is not present in this message. Returns an empty array if this attribute is present, but contains no addresses.

      Specified by:
      getTo in interface MailMessage
      Returns:
      immutable list of Strings containing the addresses of the primary recipients
    • setTo

      public void setTo(String address)
      Description copied from interface: MailMessage
      Set the "To" attribute address in this message.
      Specified by:
      setTo in interface MailMessage
      Parameters:
      address - the primary recipient address
    • setTo

      public void setTo(org.eclipse.collections.api.list.ImmutableList<String> addresses)
      Description copied from interface: MailMessage
      Set the "To" attribute addresses in this message.
      Specified by:
      setTo in interface MailMessage
      Parameters:
      addresses - the primary recipient addresses
    • addTo

      public void addTo(org.eclipse.collections.api.list.ImmutableList<String> addresses)
      Description copied from interface: MailMessage
      Add these addresses to the existing "To" attribute.
      Specified by:
      addTo in interface MailMessage
      Parameters:
      addresses - the primary recipient addresses
    • getCc

      public org.eclipse.collections.api.list.ImmutableList<String> getCc()
      Description copied from interface: MailMessage
      Return the "Cc" attribute addresses. The "Cc" attribute contains secondary recipients of this message.

      This method returns null if this attribute is not present in this message. Returns an empty array if this attribute is present, but contains no addresses.

      Specified by:
      getCc in interface MailMessage
      Returns:
      immutable list of Strings containing the addresses of the secondary recipients
    • setCc

      public void setCc(org.eclipse.collections.api.list.ImmutableList<String> addresses)
      Description copied from interface: MailMessage
      Set the "Cc" attribute addresses in this message.
      Specified by:
      setCc in interface MailMessage
      Parameters:
      addresses - the secondary recipient addresses
    • addCc

      public void addCc(org.eclipse.collections.api.list.ImmutableList<String> addresses)
      Description copied from interface: MailMessage
      Add these addresses to the existing "Cc" attribute.
      Specified by:
      addCc in interface MailMessage
      Parameters:
      addresses - the secondary recipient addresses
    • getBcc

      public org.eclipse.collections.api.list.ImmutableList<String> getBcc()
      Description copied from interface: MailMessage
      Return the "Bcc" attribute addresses. The "Bcc" attribute contains tertiary recipients of this message.

      This method returns null if this attribute is not present in this message. Returns an empty array if this attribute is present, but contains no addresses.

      Specified by:
      getBcc in interface MailMessage
      Returns:
      immutable list of Strings containing the addresses of the tertiary recipients
    • setBcc

      public void setBcc(org.eclipse.collections.api.list.ImmutableList<String> addresses)
      Description copied from interface: MailMessage
      Set the "Bcc" attribute addresses in this message.
      Specified by:
      setBcc in interface MailMessage
      Parameters:
      addresses - the tertiary recipient addresses
    • addBcc

      public void addBcc(org.eclipse.collections.api.list.ImmutableList<String> addresses)
      Description copied from interface: MailMessage
      Add these addresses to the existing "Bcc" attribute.
      Specified by:
      addBcc in interface MailMessage
      Parameters:
      addresses - the tertiary recipient addresses
    • getAllRecipients

      public org.eclipse.collections.api.list.ImmutableList<String> getAllRecipients()
      Description copied from interface: MailMessage
      Get all the recipients of this message. This method returns null if the corresponding header is not present. Returns an empty array if the header is present, but contains no addresses.
      Specified by:
      getAllRecipients in interface MailMessage
      Returns:
      all the recipients of this message
    • getReplyTo

      public org.eclipse.collections.api.list.ImmutableList<String> getReplyTo()
      Description copied from interface: MailMessage
      Get 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 getFrom method.

      This method returns null if the corresponding header is not present. Returns an empty array if the header is present, but contains no addresses.

      Specified by:
      getReplyTo in interface MailMessage
      Returns:
      addresses to which replies should be directed
      See Also:
    • setReplyTo

      public void setReplyTo(org.eclipse.collections.api.list.ImmutableList<String> addresses)
      Description copied from interface: MailMessage
      Set 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:
      setReplyTo in interface MailMessage
      Parameters:
      addresses - addresses to which replies should be directed
    • getSubject

      public String getSubject()
      Description copied from interface: MailMessage
      Get the subject of this message.
      Specified by:
      getSubject in interface MailMessage
      Returns:
      the subject string
    • setSubject

      public void setSubject(String subject)
      Description copied from interface: MailMessage
      Set the subject of this message.
      Specified by:
      setSubject in interface MailMessage
      Parameters:
      subject - the subject string
    • setText

      public void setText(String text)
      Description copied from interface: MailMessage
      A convenience method that sets the given String as this part's content with a MIME type of "text/plain".
      Specified by:
      setText in interface MailMessage
      Parameters:
      text - the text that is the message's content
    • setHtml

      public void setHtml(String htmlText)
      Description copied from interface: MailMessage
      A convenience method that sets the given String as this part's content with a MIME type of "text/html".
      Specified by:
      setHtml in interface MailMessage
      Parameters:
      htmlText - the html content that is the message's content
    • addAttachment

      public void addAttachment(File file)
      Description copied from interface: MailMessage
      Adds a File as an attachment to this message.
      Specified by:
      addAttachment in interface MailMessage
      Parameters:
      file - the file to attach
    • addAttachment

      public void addAttachment(File file, String cid)
      Description copied from interface: MailMessage
      Adds a File as an attachment to this message with the given content ID.
      Specified by:
      addAttachment in interface MailMessage
      Parameters:
      file - the file to attach
      cid - the "Content-ID" of the attachment
    • addAttachment

      public void addAttachment(File file, String contentType, String encoding)
      Description copied from interface: MailMessage
      Adds a File as an attachment to this message with the given content type and encoding.
      Specified by:
      addAttachment in interface MailMessage
      Parameters:
      file - the file to attach
      contentType - the content type of the file
      encoding - the encoding of the file
    • getSentDate

      public Instant getSentDate()
      Description copied from interface: MailMessage
      Get the date this message was sent.
      Specified by:
      getSentDate in interface MailMessage
      Returns:
      the instant this message was sent
    • setSentDate

      public void setSentDate(Instant instant)
      Description copied from interface: MailMessage
      Set the sent date of this message.
      Specified by:
      setSentDate in interface MailMessage
      Parameters:
      instant - the instant this message was sent
    • getReceivedDate

      public Instant getReceivedDate()
      Description copied from interface: MailMessage
      Get the date this message was received.
      Specified by:
      getReceivedDate in interface MailMessage
      Returns:
      the instant this message was received
    • saveChanges

      public CompletableFuture<Void> saveChanges()
      Description copied from interface: MailMessage
      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. 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 saveChanges should not be called on such messages.

      Specified by:
      saveChanges in interface MailMessage
      Returns:
      a CompletableFuture that completes when the changes are saved
    • send

      public CompletableFuture<Void> send()
      Description copied from interface: MailMessage
      Send a message. The message will be sent to all recipient addresses specified in the message (as returned from the method MailMessage.getAllRecipients()), using message transports appropriate to each address. The send method calls the saveChanges method on the message before sending it.

      In typical usage, a MailException reflects an error detected by the server. The details of the MailException will 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:
      send in interface MailMessage
      Returns:
      a CompletableFuture that 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: MailMessage
      Send the message to the specified addresses, ignoring any recipients specified in the message itself. The send method calls the saveChanges method on the message before sending it.
      Specified by:
      send in interface MailMessage
      Parameters:
      addresses - the addresses to which to send the message
      Returns:
      a CompletableFuture that completes when the message is sent
      See Also: