Class EmailResultActionBuilder
java.lang.Object
com.inet.taskplanner.server.api.action.EmailResultActionBuilder
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 Summary
ConstructorsConstructorDescriptionEmailResultActionBuilder
(String subject, String message, String... receiver) Creates a new EmailResultBuilder with subject, message and receiver.
This will add file based results as attachments. -
Method Summary
Modifier and TypeMethodDescriptioncreate()
Finish construction of theEmailResultAction
and construct a definition object which can be added to atask
.withAttachendFiles
(boolean attachFiles) Specify whetherFile-based
results must be appended to the email as attachments.withFilenameFormat
(@Nonnull String filenameFormat) Set the filename format of the attachments of the email.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 EmailResultBuilder with subject, message and receiver.
This will add file based results as attachments.- Parameters:
subject
- the subject for the email, seewithSubject(String)
.message
- the message for the email, seewithMessage(String)
receiver
- the receivers for the email, seewithReceiver(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
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
Specify whetherFile-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
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
Finish construction of theEmailResultAction
and construct a definition object which can be added to atask
.- Returns:
- the new created Definition containing the settings of this builder
- Since:
- taskplanner 3.0
-