Class EmailResultActionBuilder

java.lang.Object
com.inet.taskplanner.server.api.action.EmailResultActionBuilder

public class EmailResultActionBuilder extends Object
Use this to easily create definitions for an email result action. This action sends an email to the specified recipients with the created files.

Example usage:

TaskDefinition task = new TaskDefinition( "mytask" );
//Send email to office manager and m.fayris
String message = generateEmailBodyHtml();
ResultActionDefinition definition = new EmailResultActionBuilder( "Monthly result report", message, "office@dep1.company.com", "mfayris@dep1.company.com" ).create();
task.addResultAction( definition );

// .. add jobs and triggers ...

TaskPlanner.getInstance().addTask( task, userID );

The [jobresult] placeholder

The placeholder '[jobresult]' can be used for the subject and the message, but it usually makes only sense in the message. That placeholder is replaced with the contents of text-based results or html-results. That means if a job produces text or HTML, that content appears at the placeholder's location. If an HTML result replaces the placeholder, the type of the email becomes HTML automatically.

Since:
taskplanner 3.0
  • Constructor Details

    • EmailResultActionBuilder

      public EmailResultActionBuilder(String subject, String message, String... receiver)
      Creates a new EmailResultActionBuilder with subject, message, and receiver.
      This adds file-based results as attachments.
      Parameters:
      subject - the subject for the email, see withSubject(String).
      message - the message for the email, see withMessage(String)
      receiver - the email recipients, see withReceiver(String...)
      Throws:
      IllegalArgumentException - if any given value is null or any given email address is invalid
      Since:
      taskplanner 3.0
  • Method Details

    • withSubject

      public EmailResultActionBuilder withSubject(@Nonnull String subject)
      Set the subject for the email.
      Parameters:
      subject - the subject of the email.
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if subject is null
      Since:
      taskplanner 3.0
    • withMessage

      public EmailResultActionBuilder withMessage(@Nonnull String message)
      Set the message of the email. This can be plain text or HTML.
      Parameters:
      message - the message text for the email
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if message is null
      Since:
      taskplanner 3.0
    • withReceiver

      public EmailResultActionBuilder withReceiver(@Nonnull String... receiver)
      Sets the addresses of the receiver(s) of the email. Each String must be a valid email address.
      Parameters:
      receiver - the receiver of the email
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if receiver is null or any of given email addresses is invalid
      Since:
      taskplanner 3.0
    • withAttachendFiles

      @Deprecated public EmailResultActionBuilder withAttachendFiles(boolean attachFiles)
      Deprecated.
      As of version 26.10, use withAttachedFiles(boolean) instead.
      Specify whether file-based results must be appended to the email as attachments. The default value is true.
      Parameters:
      attachFiles - whether file-based results must be added as attachments
      Returns:
      this builder instance.
      Since:
      taskplanner 3.0
    • withAttachedFiles

      public EmailResultActionBuilder withAttachedFiles(boolean attachFiles)
      Specifies whether file-based results must be appended to the email as attachments. The default value is true.
      Parameters:
      attachFiles - whether file-based results must be added as attachments
      Returns:
      this builder instance
      Since:
      taskplanner 26.10
    • withFilenameFormat

      public EmailResultActionBuilder withFilenameFormat(@Nonnull String filenameFormat)
      Sets the filename format of the email attachments.
      Parameters:
      filenameFormat - the filename format of the attachments
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if filenameFormat is null or empty
      Since:
      taskplanner 3.1
    • create

      public ResultActionDefinition create()
      Finishes construction of the EmailResultAction and constructs a definition object that can be added to a task.
      Returns:
      the newly created definition containing the settings of this builder
      Since:
      taskplanner 3.0