Class MailAPI

java.lang.Object
com.jedox.etl.components.scriptapi.MailAPI

public class MailAPI extends Object
Utility class to send emails via SMTP.

Uses SMTP settings from Jedox Cloud Console.

Get the utility with ExecutionAPI.getMailer(), compose the email with addRecipient(String), setSubject(String) and setMessage(String). After the email is complete, send it with send().


 mailer = API.getMailer()
 mailer.addRecipient("max.mustermann@example.com")
 mailer.setSubject("Hello")
 mailer.setMessage("Hello from Jedox Integrator!")
 mailer.send()
 
Note: as of Jedox 24.2, SMTP settings are configured in Jedox Cloud Console. Configuring SMTP settings in scripts is no longer possible. All affected methods like setServer() are now deprecated. Calling any of these methods has no effect or returns null or false, and a warning will be logged, notifying about the deprecation.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds an email attachment.
    void
    Adds a blind carbon copy email recipient (Bcc)).
    void
    Adds a carbon copy email recipient (Cc)).
    void
    addRecipient(String recipient)
    Adds an email recipient (To).
    void
    enableAuth(boolean auth)
    Deprecated, for removal: This API element is subject to removal in a future version.
    As of Jedox 24.2, calling this method has no effect.
    void
    enableTLS(boolean tls)
    Deprecated, for removal: This API element is subject to removal in a future version.
    As of Jedox 24.2, calling this method has no effect.
    Returns the attachments added to the current email.
    Returns the list of blind carbon copy recipients.
    Returns the list of carbon copy recipients.
    Deprecated, for removal: This API element is subject to removal in a future version.
    As of Jedox 24.2, calling this method returns null.
    Returns the list of email recipients (To).
    Returns the message text (BODY) of the email.
    Deprecated, for removal: This API element is subject to removal in a future version.
    As of Jedox 24.2, calling this method returns null.
    Returns the email subject.
    Deprecated, for removal: This API element is subject to removal in a future version.
    As of Jedox 24.2, calling this method returns null.
    Deprecated, for removal: This API element is subject to removal in a future version.
    As of Jedox 24.2, calling this method returns null.
    Deprecated, for removal: This API element is subject to removal in a future version.
    As of Jedox 24.2, calling this method returns null.
    Deprecated, for removal: This API element is subject to removal in a future version.
    As of Jedox 24.2, calling this method returns null.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    As of Jedox 24.2, calling this method returns false.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    As of Jedox 24.2, calling this method returns false.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    As of Jedox 24.2, calling this method returns false.
    void
    Reset the current email fields.
    void
    Sends an email once its composition is complete.
    void
    Sets the email body (MIME type text/html).
    void
    setMessage(String message)
    Sets the email body (MIME type text/plain).
    void
    setMessage(String message, String subType)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use setMessage(String) for text/plain or setHtmlMessage(String) for messages in HTML (text/html instead.
    void
    setSender(String sender)
    Deprecated, for removal: This API element is subject to removal in a future version.
    As of Jedox 24.2, calling this method has no effect.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    As of Jedox 24.2, calling this method has no effect.
    void
    setServer(String host, String user, String password)
    Deprecated, for removal: This API element is subject to removal in a future version.
    As of Jedox 24.2, calling this method has no effect.
    void
    setSMTPServer(String host, String port, String user, String password)
    Deprecated, for removal: This API element is subject to removal in a future version.
    As of Jedox 24.2, calling this method has no effect.
    void
    setSubject(String subject)
    Sets the email subject.
    void
    trustAllServers(boolean trustAllServers)
    Deprecated, for removal: This API element is subject to removal in a future version.
    As of Jedox 24.2, calling this method has no effect.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MailAPI

      public MailAPI() throws com.jedox.etl.components.scriptapi.MailAPI.MailException
      Throws:
      com.jedox.etl.components.scriptapi.MailAPI.MailException
  • Method Details

    • setServer

      @Deprecated(since="24.2", forRemoval=true) public void setServer(String host, String user, String password)
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Jedox 24.2, calling this method has no effect. SMTP settings are now configured in Jedox Cloud Console.
      Sets SMTP host and user and password.
      Parameters:
      host - the SMTP host
      user - the user for authentication
      password - the password for authentication
    • setServer

      @Deprecated(since="24.2", forRemoval=true) public void setServer()
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Jedox 24.2, calling this method has no effect. SMTP settings are now configured in Jedox Cloud Console.
      Sets server.
    • setSMTPServer

      @Deprecated(since="24.2", forRemoval=true) public void setSMTPServer(String host, String port, String user, String password)
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Jedox 24.2, calling this method has no effect. SMTP settings are now configured in Jedox Cloud Console.
      Sets required configuration values for the SMTP connection.
      Parameters:
      host - the SMTP host
      port - the port to use
      user - the user for authentication, if sender (From) is not explicitly set, this value is also used for sender (From)
      password - the password for authentication
    • setSender

      @Deprecated(since="24.2", forRemoval=true) public void setSender(String sender)
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Jedox 24.2, calling this method has no effect. SMTP settings are now configured in Jedox Cloud Console.
      Sets the From address of the email.
      Parameters:
      sender - the email address of the sender (From)
    • addRecipient

      public void addRecipient(String recipient)
      Adds an email recipient (To). This method can be called multiple times to add more than one recipient.
      Parameters:
      recipient - email address of a recipient (To)
    • addCcRecipient

      public void addCcRecipient(String recipient)
      Adds a carbon copy email recipient (Cc)). This method can be called multiple times to add more than one carbon copy recipient.
      Parameters:
      recipient - email address of a carbon copy recipient (Cc)
    • addBccRecipient

      public void addBccRecipient(String recipient)
      Adds a blind carbon copy email recipient (Bcc)). This method can be called multiple times to add more than one blind carbon copy recipient.
      Parameters:
      recipient - email address of a blind carbon copy recipient (Bcc)
    • addAttachment

      public void addAttachment(String filename) throws com.jedox.etl.components.scriptapi.MailAPI.MailException
      Adds an email attachment. This method can be called multiple times to add more than one email attachment.
      Parameters:
      filename - the filename of the attachment (e.g. filename.txt), the path (similar to file-based connections with location type FileSystem) is relative to the local files folder
      Throws:
      com.jedox.etl.components.scriptapi.MailAPI.MailException - if the file doesn't exist or if access to the file is denied
    • setSubject

      public void setSubject(String subject)
      Sets the email subject.
      Parameters:
      subject - the subject of the email
    • setMessage

      public void setMessage(String message)
      Sets the email body (MIME type text/plain).
      Parameters:
      message - the text of the email body
    • setMessage

      @Deprecated(since="24.2", forRemoval=true) public void setMessage(String message, String subType)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use setMessage(String) for text/plain or setHtmlMessage(String) for messages in HTML (text/html instead. Any other value for subType is ignored and MIME type text/plain is used (setMessage(String) is called).
      Sets the email body.
      Parameters:
      message - the text of the email body
      subType - the MIME subtype to use (e.g. "html")
    • setHtmlMessage

      public void setHtmlMessage(String message)
      Sets the email body (MIME type text/html).
      Parameters:
      message - the email body in HTML
    • enableTLS

      @Deprecated(since="24.2", forRemoval=true) public void enableTLS(boolean tls)
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Jedox 24.2, calling this method has no effect. SMTP settings are now configured in Jedox Cloud Console.
      Enables TLS for the connection to the SMTP host.
      Parameters:
      tls - true to enable TLS, false otherwise
    • enableAuth

      @Deprecated(since="24.2", forRemoval=true) public void enableAuth(boolean auth)
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Jedox 24.2, calling this method has no effect. SMTP settings are now configured in Jedox Cloud Console.
      Enables authentication for the SMTP connection.
      Parameters:
      auth - true to enable authentication, false otherwise
    • trustAllServers

      @Deprecated(since="24.2", forRemoval=true) public void trustAllServers(boolean trustAllServers)
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Jedox 24.2, calling this method has no effect. SMTP settings are now configured in Jedox Cloud Console.
      Configures the SMTP connection to trust the configured SMTP host. If disabled, trust depends on the certificate the server presents.
      Parameters:
      trustAllServers - true to trust the configured SMTP host, false to trust the SMTP host depending on the certificate it presents
    • send

      public void send() throws com.jedox.etl.components.scriptapi.MailAPI.MailException
      Sends an email once its composition is complete.
      Throws:
      com.jedox.etl.components.scriptapi.MailAPI.MailException - if an error occurs while sending the email via SMTP
    • reset

      public void reset()
      Reset the current email fields. Does not reset the configuration properties of the SMTP connection.
    • getSmtpHostName

      @Deprecated(since="24.2", forRemoval=true) public String getSmtpHostName()
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Jedox 24.2, calling this method returns null. SMTP settings are now configured in Jedox Cloud Console.
      Returns the SMTP host name.
      Returns:
      the SMTP host name
    • getSmtpPort

      @Deprecated(since="24.2", forRemoval=true) public String getSmtpPort()
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Jedox 24.2, calling this method returns null. SMTP settings are now configured in Jedox Cloud Console.
      Returns the SMTP port.
      Returns:
      the SMTP port
    • getSmtpAuthUser

      @Deprecated(since="24.2", forRemoval=true) public String getSmtpAuthUser()
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Jedox 24.2, calling this method returns null. SMTP settings are now configured in Jedox Cloud Console.
      Returns the user for SMTP authentication.
      Returns:
      the user for authentication
    • getSmtpAuthPwd

      @Deprecated(since="24.2", forRemoval=true) public String getSmtpAuthPwd()
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Jedox 24.2, calling this method returns null. SMTP settings are now configured in Jedox Cloud Console.
      Returns the password for SMTP authentication.
      Returns:
      the password for authentication
    • getEmailMsgTxt

      public String getEmailMsgTxt()
      Returns the message text (BODY) of the email.
      Returns:
      the message text of the email
    • getEmailMsgTxtSubType

      @Deprecated(since="24.2", forRemoval=true) public String getEmailMsgTxtSubType()
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Jedox 24.2, calling this method returns null. SMTP settings are now configured in Jedox Cloud Console.
      Returns the MIME subtype (e.g. "html") of the email.
      Returns:
      the MIME subtype of the email
    • getEmailSubjectTxt

      public String getEmailSubjectTxt()
      Returns the email subject.
      Returns:
      the email subject
    • getEmailFromAddress

      @Deprecated(since="24.2", forRemoval=true) public String getEmailFromAddress()
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Jedox 24.2, calling this method returns null. SMTP settings are now configured in Jedox Cloud Console.
      Returns the email sender (From).
      Returns:
      the email sender (From)
    • isTls

      @Deprecated(since="24.2", forRemoval=true) public boolean isTls()
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Jedox 24.2, calling this method returns false. SMTP settings are now configured in Jedox Cloud Console.
      Tests if TLS is enabled for the connection to the SMTP host.
      Returns:
      true if TLS is enabled, false otherwise
    • isAuth

      @Deprecated(since="24.2", forRemoval=true) public boolean isAuth()
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Jedox 24.2, calling this method returns false. SMTP settings are now configured in Jedox Cloud Console.
      Tests if authentication is enabled for the SMTP connection.
      Returns:
      true if authentication is enabled, false otherwise
    • isTrustAllServers

      @Deprecated(since="24.2", forRemoval=true) public boolean isTrustAllServers()
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Jedox 24.2, calling this method returns false. SMTP settings are now configured in Jedox Cloud Console.
      Tests if the SMTP connection is configured to trust the configured SMTP host. If disabled, trust depends on the certificate the server presents
      Returns:
      true if the SMTP connection is configured to trust the configured SMTP host, false otherwise
    • getEmailList

      public Set<String> getEmailList()
      Returns the list of email recipients (To).
      Returns:
      the list of email recipients (To) as a Set
    • getCcList

      public Set<String> getCcList()
      Returns the list of carbon copy recipients.
      Returns:
      the list of carbon copy recipients as a Set
    • getBccList

      public Set<String> getBccList()
      Returns the list of blind carbon copy recipients.
      Returns:
      the list of blind carbon copy recipients as a Set
    • getAttachmentsList

      public Set<File> getAttachmentsList()
      Returns the attachments added to the current email.
      Returns:
      the list of attachments of the current email