Sending Email By AEM | Community
Skip to main content
Level 2
October 16, 2015
Solved

Sending Email By AEM

Hi,

I have a requirement for sending a Mail from AEM using email templates. I have to hit a aem servlet from external server with required parameters and then construct the email and using aem mail templates and cq mail service shoot the mail. Could anyone please help me with it.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
narayanank84409
narayanank84409Accepted solution
Level 4
October 16, 2015

Try to use HtmlEmail.class .

I hope this code will help you.

    MessageGateway<HtmlEmail> messageGateway = messageGatewayService.getGateway(HtmlEmail.class);
                HtmlEmail email = new HtmlEmail();
                email = mailTemplate.getEmail(StrLookup.mapLookup(emailProperties), HtmlEmail.class);
                List<InternetAddress> emailRecipients = new ArrayList<InternetAddress>();
                emailRecipients.add(new InternetAddress(request.getParameter("email")));
                email.setTo(emailRecipients);
                messageGateway.send(email);

13 replies

Level 2
October 16, 2015

I am using this URL for the package

https://github.com/Adobe-Consulting-Services/acs-aem-commons

Translate
Level 2
October 16, 2015

What is the "emailProperties" , is it a MAP containing all the params. Also I have used HtmlEmail.class, still it gives the same error

Translate
narayanank84409
Level 4
October 16, 2015

tushark60575350 wrote...

What is the "emailProperties" , is it a MAP containing all the params. Also I have used HtmlEmail.class, still it gives the same error

 

 

Yes, it's my map parameters.

I got values from Front end.

Translate