AEM Email services | Community
Skip to main content
March 27, 2020
Solved

AEM Email services

  • March 27, 2020
  • 1 reply
  • 1354 views

Hi,

We are currently using AEM Email Services(acs-aem-commons-bundle-3.18.2.jar) for sending out an html email. 

 

Example code:

 

Using the Email API to send mails

The EmailService is an OSGi service and can be injected using @3214626 in the calling class.

	@Reference
	EmailService emailService;

	emailService.sendEmail(templatePath, emailParams, recipients);



 

Our email template is like below

en.html:

From: admin@adobe.com
Subject: Greetings
CC: ${ccrecipient}
BCC: ${bccrecipient}

<div style="color: blue;">

Hello ${recipientName}

Find your message here: ${message}

From,
Adobe Team

 

 

Could you please clarify how to include conditional field in this email template. Like, we need to add a condition like below as like velocity or freemarker email templates.

 

if condition 1 then {$message} else {$message2}

 

Please assit.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by BrianKasingli

@developerssp_48,

There aren't any clever things you can do with the ACS Commons Email feature to dynamically render your HTML email template other than having different variations of templates, example:

 

if (emailParms.containsKey("offers") && emailParms.get("offers") != null) { emailService.sendEmail(emailTplOffers, emailParams, recipients); } else { emailService.sendEmail(emailTplGeneric, emailParams, recipients); }

 

 Hope this helps,

Brian.

1 reply

BrianKasingli
Community Advisor and Adobe Champion
BrianKasingliCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
March 28, 2020

@developerssp_48,

There aren't any clever things you can do with the ACS Commons Email feature to dynamically render your HTML email template other than having different variations of templates, example:

 

if (emailParms.containsKey("offers") && emailParms.get("offers") != null) { emailService.sendEmail(emailTplOffers, emailParams, recipients); } else { emailService.sendEmail(emailTplGeneric, emailParams, recipients); }

 

 Hope this helps,

Brian.