Hi Team,
We have the default email notification that is used in workflow at /etc/workflow/notification/email/default/en.txt location. I have created my own email notification template at /etc/workflow/notification/email/myproject/en.txt. I'm using "Dynamic Participant Step" in my workflow and checked "Email" checkbox in order to send the email notification. It is using the default email template. Where can I specify my custom template to use in workflow?
Please suggest.
Thanks,
AryA.
Solved! Go to Solution.
We are writing a HELPX article to show how to use the MessageServiceGateWay API to send emails based on a template. And how to populate it via a MAP object that contains key/values. But as i stated in my first response - to use a custom EMail template in a workflow - you need to write a custom WORKFLOW Step then Java such as:
//Sends HTML email based on an AEM Template
private void SendHHTMLEmail(SlingHttpServletRequest request)
{
try
{
Map myMap = new HashMap() ;
myMap.put("host.prefix","Foo"); //use a map entry for each variable to populate
//Declare a MessageGateway service
MessageGateway<HtmlEmail> messageGateway;
//Specify the EMail template to use in email
String template ="/etc/notification/email/html/com.day.cq.collab.forum/en.txt";
Resource templateRsrc = request.getResourceResolver().getResource(template);
String path = templateRsrc.getPath();
MailTemplate mailTemplate = MailTemplate.create(templateRsrc.getPath(), templateRsrc.getResourceResolver().adaptTo(Session.class));
HtmlEmail email = mailTemplate.getEmail(StrLookup.mapLookup(myMap), HtmlEmail.class);
email.addTo("scottm@adobe.com");
email.setSubject("AEM Email Template");
email.setFrom("smacdonald2006@hotmail.com");
//Inject a MessageGateway Service and send the message
// messageGateway = messageGatewayService.getGateway(Email.class);
messageGateway = this.messageGatewayService.getGateway(HtmlEmail.class);
// gateway.send(email);
// Check the logs to see that messageGateway is not null
messageGateway.send((HtmlEmail) email);
// messageGateway.send((Email) email);
}
catch (Exception e)
{
log.info(e.getMessage()) ;
}
}
To use a custom template in a Workflow step - write a custom step and use Java located here:
https://forums.adobe.com/thread/1107034
We have this almost in a community article:
http://scottsdigitalcommunity.blogspot.ca/2013/10/creating-custom-aem-workflow-steps-that.html
The only difference is we are not using a email template - so you would add the logic in the 1st link to the custom step.
Views
Replies
Total Likes
Also - read Dan Klco post here - he does a good job explaining how to get a custom template using Java code:
http://labs.6dglobal.com/blog/2012-08-20/sending-email-adobe-cq-api/
Views
Replies
Total Likes
We are writing a HELPX article to show how to use the MessageServiceGateWay API to send emails based on a template. And how to populate it via a MAP object that contains key/values. But as i stated in my first response - to use a custom EMail template in a workflow - you need to write a custom WORKFLOW Step then Java such as:
//Sends HTML email based on an AEM Template
private void SendHHTMLEmail(SlingHttpServletRequest request)
{
try
{
Map myMap = new HashMap() ;
myMap.put("host.prefix","Foo"); //use a map entry for each variable to populate
//Declare a MessageGateway service
MessageGateway<HtmlEmail> messageGateway;
//Specify the EMail template to use in email
String template ="/etc/notification/email/html/com.day.cq.collab.forum/en.txt";
Resource templateRsrc = request.getResourceResolver().getResource(template);
String path = templateRsrc.getPath();
MailTemplate mailTemplate = MailTemplate.create(templateRsrc.getPath(), templateRsrc.getResourceResolver().adaptTo(Session.class));
HtmlEmail email = mailTemplate.getEmail(StrLookup.mapLookup(myMap), HtmlEmail.class);
email.addTo("scottm@adobe.com");
email.setSubject("AEM Email Template");
email.setFrom("smacdonald2006@hotmail.com");
//Inject a MessageGateway Service and send the message
// messageGateway = messageGatewayService.getGateway(Email.class);
messageGateway = this.messageGatewayService.getGateway(HtmlEmail.class);
// gateway.send(email);
// Check the logs to see that messageGateway is not null
messageGateway.send((HtmlEmail) email);
// messageGateway.send((Email) email);
}
catch (Exception e)
{
log.info(e.getMessage()) ;
}
}
Thanks Scott. Thanks for your help in offline too.
Views
Replies
Total Likes
Views
Likes
Replies