How to create a Email Template with tokens

2
I could create an email template and it works. But now i want to create email template with placeholders which i can replace while sending email, is there a link which gives step by step how to achieve this.    
asked
1 answers
6

Hi Abhinav,

So you probably already downloaded all necesairly modules since you need this for being able to run the email template modules.

So the first thing you start is to define an object which you want to pass to use to replace tokens. So let's say in this case it's called MailData with 2 attributes. So I start with running the model reflection so I can use this token in my email template. Herefor you have to add the page MxObjects_Overview in from the _USE_ME folder from the MxModelReflection Module.

Then In selecting my token object the MailData entity is available. Now i can define my 2 members Name and Signature:

and define the message in your email template.

Now in the microflow I can create an object of the MailData and fill it with the required values. In my case I just fill it with fixed values but you can use data which you want off course.

So Now you had sending a simple mail working, So I guess you know already how to retrieve your emailtemplate. So I skip this, now when have your email template you also have to retrieve the list of tokens. Then you create your email object, fill the values and also the body from the email template. Do this before running the replace tokens action because the body is necessary for the replace token action. Then finally you can call the replace tokens action and you have a very simple version of the email templates with tokens working:

Normally we use error handling when using a java action to prevent your normal logic from failing due to unexpected errors in the add on modules.

Hope this helps.

Regards,

EDIT:

Here a model share of the microflow. I only filled the body object in the email template but other items should be configured as well off coursel.

https://modelshare.mendix.com/models/40e5e4aa-7413-4e2d-a02b-f6ea50089358/send-email

answered