Sending Email By AEM | Community
Skip to main content
New Participant
October 16, 2015
Solved

Sending Email By AEM

  • October 16, 2015
  • 13 replies
  • 12326 views

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.
Best answer by narayanank84409

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

New Participant
October 16, 2015
New Participant
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

narayanank84409
New Participant
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.