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 ResultAction. This action sends an email to specified receivers with 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 );
 

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, then that content will appear in the placeholders location. If it replaces the placeholder with html result, then the type of the email will become HTML automatically.

Since:
taskplanner 3.0
  • Constructor Details

    • EmailResultActionBuilder

      public EmailResultActionBuilder(String subject, String message, String... receiver)
      Creates a new EmailResultBuilder with subject, message and receiver.
      This will add 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 receivers for the email, see withReceiver(String...)
      Throws:
      IllegalArgumentException - if any of given values is null or any of given email addresses 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

      public EmailResultActionBuilder withAttachendFiles(boolean attachFiles)
      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
    • withFilenameFormat

      public EmailResultActionBuilder withFilenameFormat(@Nonnull String filenameFormat)
      Set the filename format of the attachments of the email.
      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()
      Finish construction of the EmailResultAction and construct a definition object which can be added to a task.
      Returns:
      the new created Definition containing the settings of this builder
      Since:
      taskplanner 3.0