Workflow Email Customizations

You can customize email notifications using the Workflow Software Development Kit (SDK).

The Workflow SDK provides an interface for sending email notifications and models of the related object. You can customize the content of email notifications using the Workflow SDK.

The following email components are available in this customization:
  • Email - contains email information
  • Attachment - describes email attachments
  • EmailService.sendEmail(Email email) - sends emails to users with appropriate content
  • EmailService.resolveTaskOwnerEmail(Task task) - resolves email addresses for a task owner
  • EmailService.resolveTaskAssigneeEmail(Task task) - resolves email addresses for a task asignee

Example: Creating a CustomTaskCompleteEventListener to Send a Custom Email

public class CustomTaskCompleteEventListener implements WorkflowTaskListener {

    @WorkflowService
    private EmailService emailService;

    public void notify(Task task) {       
        Email email = new Email();
        email.setSubject("custom email on assign");
        email.setTo(emailService.resolveTaskOwnerEmail(task));
        email.setTextBody("this is a custom email on complete");
        emailService.sendEmail(email);
    }
}
Note: Ensure that you switch off the default email notification if you want to use a custom one by setting the NotificationOnAssignmentEnabled and NotificationOnCompletionEnabled parameters to false in the process definition.