Class EmailResultActionBuilder
- java.lang.Object
-
- com.inet.taskplanner.server.api.action.EmailResultActionBuilder
-
public class EmailResultActionBuilder extends java.lang.Object
Use this to easily createdefinitions
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
Constructors Constructor Description EmailResultActionBuilder(java.lang.String subject, java.lang.String message, java.lang.String... receiver)
Creates a new EmailResultBuilder with subject, message and receiver.
This will add file based results as attachments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResultActionDefinition
create()
Finish construction of theEmailResultAction
and construct a definition object which can be added to atask
.EmailResultActionBuilder
withAttachendFiles(boolean attachFiles)
Specify whetherFile-based
results must be appended to the email as attachments.EmailResultActionBuilder
withFilenameFormat(java.lang.String filenameFormat)
Set the filename format of the attachments of the email.EmailResultActionBuilder
withMessage(java.lang.String message)
Set the message of the email.EmailResultActionBuilder
withReceiver(java.lang.String... receiver)
Sets the addresses of the receiver(s) of the email.EmailResultActionBuilder
withSubject(java.lang.String subject)
Set the subject for the email.
-
-
-
Constructor Detail
-
EmailResultActionBuilder
public EmailResultActionBuilder(java.lang.String subject, java.lang.String message, java.lang.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, seewithSubject(String)
.message
- the message for the email, seewithMessage(String)
receiver
- the receivers for the email, seewithReceiver(String...)
- Throws:
java.lang.IllegalArgumentException
- if any of given values is null or any of given email addresses is invalid- Since:
- taskplanner 3.0
-
-
Method Detail
-
withSubject
public EmailResultActionBuilder withSubject(@Nonnull java.lang.String subject)
Set the subject for the email.- Parameters:
subject
- the subject of the email.- Returns:
- this builder instance
- Throws:
java.lang.IllegalArgumentException
- if subject is null- Since:
- taskplanner 3.0
-
withMessage
public EmailResultActionBuilder withMessage(@Nonnull java.lang.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:
java.lang.IllegalArgumentException
- if message is null- Since:
- taskplanner 3.0
-
withReceiver
public EmailResultActionBuilder withReceiver(@Nonnull java.lang.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:
java.lang.IllegalArgumentException
- if receiver is null or any of given email addresses is invalid- Since:
- taskplanner 3.0
-
withAttachendFiles
public EmailResultActionBuilder withAttachendFiles(boolean attachFiles)
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
public EmailResultActionBuilder withFilenameFormat(@Nonnull java.lang.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:
java.lang.IllegalArgumentException
- if filenameFormat is null or empty- Since:
- taskplanner 3.1
-
create
public ResultActionDefinition 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
-
-