HI @supriya-hande
Basically, you have to write one process step that will be responsible for sending mail . that process step u have to configure in the workflow model.
please find the sample code to send mail
(service = WorkflowProcess.class, property = { "process.label=NotificationMail" })
public class NotificationMail implements WorkflowProcess {
private MessageGatewayService messageGatewayService;
public void execute(WorkItem item, WorkflowSession workflowSession, MetaDataMap args) throws WorkflowException {
ResourceResolver resourceResolver = workflowSession.adaptTo(ResourceResolver.class);
String path = item.getWorkflowData().getPayload().toString();
Resource resource = resourceResolver.getResource(path.concat("/jcr:content"));
ValueMap properties = resource.adaptTo(ValueMap.class);
String title = StringUtils.EMPTY;
String comment = StringUtils.EMPTY;
String userId = StringUtils.EMPTY;
if (properties.containsKey(JCRTITLE)) {
title = properties.get(JCRTITLE, String.class) + ".html";
LOGGER.info("jcrtitle+++++++++++++++++++++++++++++++++++++++++++" + title);
}
if (properties.containsKey(CQNAME)) {
title = properties.get(CQNAME, String.class);
LOGGER.info("cq:name+++++++++++++++++++++++++++++++++++++++++++" + title);
}
// Workflow wf = item.getWorkflow();
List<HistoryItem> wfHistory = workflowSession.getHistory(item.getWorkflow());
for (HistoryItem itemhistory : wfHistory) {
LOGGER.info("history iem+++++++++++++++++++++++++++++++++++++++++++" + itemhistory.getUserId());
LOGGER.info("comment+++++++++++++++++++++++++++++++++++++++++++" + itemhistory.getComment());
comment = itemhistory.getComment();
userId = itemhistory.getUserId();
}
LOGGER.info("path+++++++++++++++++++++++++++++++++++++++++++ " + path);
String owner = item.getWorkflow().getInitiator();
LOGGER.info("owner+++++++++++++++++++++++++++++++++++++++++++ " + owner);
Date startdate = item.getTimeStarted();
SimpleDateFormat mdyFormat = new SimpleDateFormat(REQDATE);
String date = mdyFormat.format(startdate.getTime());
LOGGER.info("startdate+++++++++++++++++++++++++++++++++++++++++++ " + date);
try {
// Declare a MessageGateway service
MessageGateway<Email> messageGateway;
// Set up the Email message
HtmlEmail email = new HtmlEmail();
// Set the mail values
String emailToRecipients = "Raushan.jaiswal@gmail.com";
String salutation = "<b>Dear " + owner + ",</b><br>";
String data = "<p><br><b>WorkArea:</b>\t" + path + "\t <b>Owner:\t" + userId + "\t <b>Intiated:</b>\t"
+ date + "</p>\n";
String message = "<b><p>" + owner + "</b> <b>has submitted content for your approval. "
+ "Please review at your earliest convenience. After you review the content, click the Approve/Reject button below to Approve/Reject"
+ ". If you feel that you are not the right person for approving the content, you can<a href=\"/notifications.html\"> reassign </a>this task. <b><br><br><a href= \"/notifications.html\">Approve/Reject</a>";
comment = "<b>Description and Comments :<br>Description :\t Publishes content to one or more target nodes, optionally including a review / revision loop. "
+ userId + date + "<br>Notes to Approver :\t" + comment
+ "<br>Current Task: Please review and take action";
String file = "<p><br><b>Attached Files:</b>\t</br><br>" + "<br>File Name :\t" + "<a href=\"/" + path
+ ".html\">" + title + " </a>" + " \t <b>Title:\t" + title + "</p>\n";
email.addTo(emailToRecipients);
// email.addCc(emailCcRecipients);
email.setSubject("Please review and take action ");
email.setFrom("hiraushan123@gmail.com");
email.setMsg(salutation + message + data + comment + file);
// Inject a MessageGateway Service and send the message
messageGateway = messageGatewayService.getGateway(HtmlEmail.class);
// Check the logs to see that messageGateway is not null
messageGateway.send((Email) email);
LOGGER.info("sendamil succesfully+++++++++++++++++++++");