Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Two Mail Templates in AEM Email

Avatar

Level 3

Hi Experts ,

I am writing a custom form action in AEM. My action sends email as per a predefined template. Here is the code 

MailTemplate mailTemplate = MailTemplate.create("/apps/custom_submit_action/store_and_email/temp.html", resolver.adaptTo(Session.class));

MultiPartEmail email = mailTemplate.getEmail(StrLookup.mapLookup(parameters), HtmlEmail.class);

This works fine. 

Now I have an another template /apps/custom_submit_action/store_and_email/temp.xml, I want to send the data in this template as well. I dont want to send two separate emails. So basically, I have to send data in two formats. HTML and XML. Here are my two templates

temp.html

Dear ${admin};

A new ${user} has purchased  ${product1},${product2} at ${city},${storeid}.

temp.xml

<purchase>

<customer>${customer}</customer><city>${city}</city><store>${storeid}</store></purchase>

I am looking for all possible suggestions. 

Thanks

1 Reply

Avatar

Level 10

We just wrote a similar tool in AEM- you can always write a custom OSGi service that dynamically creates email messages. You have a lot of flexibility as well For example, using Java logic and expressions, you can dynamically put together many different email messages - each with different data points, links, variables, etc.