AEM4BEGINNER blog is for Beginners who are interested in learning Adobe Experience Manager (AEM) aka Adobe CQ5 from basics. The Information provided in this blog is for learning and testing purposes only. Here, I have posted the information which I know or gathered from different sources.
AEM provides OOTB email templates to send emails for workflow notification, completion, etc. But those templates are plain text and cannot provide rich UI and limited to few dynamic properties. Example
– OOTB workflow notification email template contains plain text and
other variables like an event, work item, user, host properties, etc. More info about Email Templates for Workflow Notification at https://helpx.adobe.com/experience-manager/6-3/sites/administering/using/notification.html#ConfiguringtheWorkflowEmailNotificationService OOTB Workflow notification template
Custom Email
Custom Email Service/Servlet/Process Step:
You can create a utility/Servlet/workflow Process, whichever trigger
the email and use com.day.cq.mailer.MessageGatewayService to send
template based email. Add Below dependencies in POM. or check dependencies using dependency finder at http://localhost:4504/system/console/depfinder Dependencies in POMCreate a utility class, In this class inject MessageGatewayService
service using Reference annotation and Create a map with all the dynamic
properties. e.g. @Reference private MessageGatewayService messageGatewayService;
final Map<String, String> parameters = new HashMap<String, String>(); parameters.put(“title”, “Demo Email”); Create org.apache.commons.mail.HTML email class object with template and map parameters. HtmlEmail email = mailTemplate.getEmail(StrLookup.mapLookup(parameters), HtmlEmail.class); Find the below Servlet Example for complete code – https://github.com/arunpatidar02/aem63app-repo/blob/master/java/email/HTMLEmailServlet.java
No comments:
Post a Comment
If you have any doubts or questions, please let us know.