Wednesday 26 June 2019

Index

List of Articles


  1. AEMaaCS  - Core Component's Children Editor
  2. AEMaaCS - Authoring - Component Markdown as help document
  3. AEM - Authoring - Page Status Visualisation
  4. AEMaaCS - ACS AEM Commons, Netcentric Accesscontroltool and AEM Groovy Console
  5. AEMaaCS - Authoring - Asset Selector in Dialog
  6. AEMaaCS - Touch UI Dialog - Dynamic Dropdown
  7. AEMaaCS - Setup JDK11, Author, Publish and Dispatcher
  8. AEM - cq:isContainer Property in AEM
  9. AEM - Touch UI Dialog | Field Description with Image
  10. AEM - Restrict Allowed Component Group in Template Policy
  11. AEM - Restricting CRXDE Access for few users
  12. AEM - Retry Failed Workflow Item using Curl and Java
  13. AEM - Authoring - Multifield Counter
  14. AEM - Touch UI Dialog | Display fields in the same row | Two Column Layout
  15. AEM - Touch UI Dialog - Assets Panel
  16. AEM - Touch UI - RTE HTML Element Selector, Custom Style Plugin & Color Picker Plugin
  17. AEM - Create OSGI Configuration Factory Service using R6 annotations
  18. AEM - Get JSON response of an AEM Page
  19. AEM - Populate Touch UI dropdown from JSON file/Servlet
  20. AEM - Granite Custom Render Conditions using Servlet
  21. AEM - Add button in site console's action toolbar to open pages in disabled mode
  22. AEM - Custom Template'd Email
  23. AEM - OSGi Config Dashboard
  24. AEM - Touch UI Component Dialog Field Regex/Custom Validation
  25. AEM - Restrict Component Editing and Allowed Only for Certain Users
  26. AEM - Content Fragment with Component
  27. AEM - Search/Filter Touch UI Dialog Dropdown
  28. AEM - Sling Feature Flags

Wednesday 12 June 2019

AEM - Custom Template'd Email

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, workitem, 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





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
Pom dependencies
Create 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.HtmlEmail 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



Custom Email template.txt

You can create a custom HTML5 template like an HTML page and save it as .txt in CRX repository wherever you want.
All the variable values can be replaced with properties set in the code e.g. ${title}

Example template available at 
https://github.com/arunpatidar02/aem63app-repo/blob/master/java/email/html5-template.txt


OSGi Config to Send an email:

For AEM to be able to send emails, the Day CQ Mail Service needs to be properly configured. Please check at
https://helpx.adobe.com/experience-manager/6-3/sites/administering/using/notification.html#configmail

Sample configuration for sending email using Gmail SMTP server


That’s it. Find the sample email trigger by https://github.com/arunpatidar02/aem63app-repo/blob/master/java/email/HTMLEmailServlet.java servlet.





Find the complete code used in this blog at Github.

AEMaaCS - Core Component's Children Editor

If you are using core components, you should be familiar with the children-editor for Tabs, Accordion, and Carousel. These components are th...

About Me

My photo
https://www.linkedin.com/in/arunpatidar26/ https://experienceleaguecommunities.adobe.com/t5/user/viewprofilepage/user-id/6786635 https://community.adobe.com/t5/user/viewprofilepage/user-id/12372253 https://forums.adobe.com/people/Arun+Patidar