Class EmailResultActionBuilder
java.lang.Object
com.inet.taskplanner.server.api.action.EmailResultActionBuilder
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 Summary
ConstructorsConstructorDescriptionEmailResultActionBuilder(String subject, String message, String... receiver) Creates a new EmailResultActionBuilder with subject, message, and receiver.
This adds file-based results as attachments. -
Method Summary
Modifier and TypeMethodDescriptioncreate()Finishes construction of theEmailResultActionand constructs a definition object that can be added to atask.withAttachedFiles(boolean attachFiles) Specifies whetherfile-basedresults must be appended to the email as attachments.withAttachendFiles(boolean attachFiles) Deprecated.withFilenameFormat(@Nonnull String filenameFormat) Sets the filename format of the email attachments.withMessage(@Nonnull String message) Set the message of the email.withReceiver(@Nonnull String... receiver) Sets the addresses of the receiver(s) of the email.withSubject(@Nonnull String subject) Set the subject for the email.
-
Constructor Details
-
EmailResultActionBuilder
Creates a new EmailResultActionBuilder with subject, message, and receiver.
This adds file-based results as attachments.- Parameters:
subject- the subject for the email, seewithSubject(String).message- the message for the email, seewithMessage(String)receiver- the email recipients, seewithReceiver(String...)- Throws:
IllegalArgumentException- if any given value is null or any given email address is invalid- Since:
- taskplanner 3.0
-
-
Method Details
-
withSubject
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
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
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.As of version 26.10, usewithAttachedFiles(boolean)instead.Specify whetherfile-basedresults 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
Specifies whetherfile-basedresults 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
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
Finishes construction of theEmailResultActionand constructs a definition object that can be added to atask.- Returns:
- the newly created definition containing the settings of this builder
- Since:
- taskplanner 3.0
-
withAttachedFiles(boolean)instead.