Skip to main content
Groovy Script - Send Custom Email Notification
Updated over a month ago

Description: Sample groovy script to send custom email notification

Context: Document/App

Remark: Accessible in 'Post' task mode only

Script:

def execute(){

// Prepare Recipient List

List<String> listToReceipient = new ArrayList<>();

listToReceipient.add("abc@example.com");

// Prepare customEmail data

Map<String, Object> emailDataMap = new HashMap<String, Object>();

emailDataMap.put(IGroovyConstant.RECEIPIENT_USERS, listToReceipient);

emailDataMap.put(IGroovyConstant.TEMPLATE_NAME, "workflowEmailTemplate.ftl"); // Name of Email template, do not change it.

emailDataMap.put(IGroovyConstant.TEMPLATE_TYPE, IGroovyConstant.EMAIL_TEMPLATE_TYPE_GENERIC);

// Make sure name of these dynamic variables should match with the email template, as the same are there in template as well.

Map<String, String> dynamicVariables = new HashMap<String, String>();

// Email Body

dynamicVariables.put("salutation", "Dear ABC");

dynamicVariables.put("HeaderLine", "Thanks for submitting your Application. You can now submit your documents by clicking on \"My Application\" Tab.");

dynamicVariables.put("BodyContent","Step by Step Process:</br>1. Click on \"My Application\" Tab </br>2. Click on \"Upload Documents\" button next to your application, to select relevant files.</br>3. You can upload multiple documents at once by clicking on \"Select Files\".");

dynamicVariables.put("FooterLine", "");

dynamicVariables.put("Closing", "Warm Regards!");

dynamicVariables.put("SenderName", "Asite Team");

emailDataMap.put(IGroovyConstant.TEMPLATE_DATA, dynamicVariables);

emailDataMap.put(IGroovyConstant.SUBJECT, "Application Submitted Successfully!");

//send notification mail to users

notificationService.sendMail(emailDataMap);

}



Did this answer your question?