How to create an object that can be used in email templates

cancel
Showing results for 
Search instead for 
Did you mean: 
hiten_rastogi1
Established Member

How to create an object that can be used in email templates

Hi,

I am want to replace Alfresco in OOTB email templates with my custom name let say ABC.

As I might need to do for many clients, replacing Alfresco from all the email templates every time for each client doesn't seems feasible, hence I want to replace it with an object that can be used as placeholder for the clients name similar to shareUrl object in the email templates

E.g.

in following-email.html.ftl we have a line Sincerely Alfresco I want replace it with Sincerely ${myObject} this myObject will contain the name of the client ABC.

myObject value will be defined in alfresco-global.propsand the templates will be bootstrapped using ImportComponentModule.

Thanks

Hiten Rastogi

3 Replies
kalpesh_c2
Senior Member

Re: How to create an object that can be used in email templates

This is sample script code to send email.

var mail = actions.create("mail");
mail.parameters.to_many = "user_email";
mail.parameters.subject = "Notification review";
mail.parameters.template = companyhome.childByNamePath("Data Dictionary/EMail Templates/Email_Templates.ftl");

var templateArgs = new Array();

templateArgs['name'] = person.properties.firstName+" "+person.properties.lastName;

var templateModel = new Array();
templateModel['args'] = templateArgs;
mail.parameters.template_model = templateModel;
mail.executeAsynchronously(person);

And this is email template file place this file under the path Data Dictionary/EMail Templates/Email_Templates.ftl

<html>
<head>
</head>
  <body bgcolor="white">
    <div>
     <p>Hi <b>${args.name},</b></p>
    </div>
</body>
</html>
companyhome.childByNamePath("Data Dictionary/EMail Templates/Email_Templates.ftl");

This path defines the location of your email template.

We need to pass templateArgs array values to template_model.

Thanks,
Kalpesh

ContCentric

hiten_rastogi1
Established Member

Re: How to create an object that can be used in email templates

Hi Kaplesh,

Thanks for your response but what I am seeking is an object that is similar to shareUrl that can contain my value and can be used in any email templates without worrying to passing it in the template model every time.

Thanks

hiten_rastogi1
Established Member

Re: How to create an object that can be used in email templates

I was able to achieve this by using message object.

Putting this ${message("client.name")} in the email templates helped me picked up the value for the labels from my properties file in the repo.

Thanks