Email Tool with Template

Introduction

The Email Tool with Template process tool plugin allows you to send email messages to target recipients using a common body template via a hash variable. By leveraging the $(body) in the Message Body Template, you can display dynamic content inside the email's message field.

Get started

Where to get the plugin

You can get the plugin from the Joget Marketplace or the Joget OSS repository.

How to install

  1. Download the plugin JAR file from the Joget Marketplace or the Joget OSS repository.
  2. Go to Settings > Manage Plugins > Upload Plugin.
  3. Once uploaded, the plugin will be available in your Joget environment.

How to use it

Define your message template

In the Message Body Template field of the plugin, use the $(body) placeholder to inject dynamic content into your email. To organize your email templates, it's best to store them in an environment hash variable or a form row.

Create an environment variable

Create a new environment variable (e.g., template) and input the following HTML code to structure your email:

<table role="presentation" align="center" border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#F3F2EF" style="background-color: rgb(243, 242, 239); table-layout: fixed; padding-bottom:30px">
   <tbody>
    <tr>
        <td align="center" style="padding-top: 24px;">
             <center style="width: 100%;">
             <table role="presentation" border="0" cellspacing="0" cellpadding="0" width="512" bgcolor="#FFFFFF" style="background-color: rgb(255, 255, 255); margin: 0px auto; max-width: 512px; width: inherit;">
                     <tbody>
                         <tr>
                             <td bgcolor="#FFFFFF" style="background-color: rgb(255, 255, 255); padding: 18px 24px 0px;">
                                 <table role="presentation" border="0" cellspacing="0" cellpadding="0" width="100%" style="width: 100%; min-width: 100%;">
                                     <tbody> <tr> <td align="center" valign="middle">
                                     <h2 style="margin:0;color:#000000;font-weight:600;font-size:24px;line-height:1.167">Claim App</h2>
                                     </td></tr></tbody>
                                 </table>
                             </td>
                         </tr>
                     </tbody>
             </table>
             </center>
         </td>
     </tr>
     <tr>
        <td align="center">
             <center style="width: 100%;">
             <table role="presentation" border="0" cellspacing="0" cellpadding="0" width="512" bgcolor="#FFFFFF" style="background-color: rgb(255, 255, 255); margin: 0px auto; max-width: 512px; width: inherit;">
                     <tbody>
                         <tr>
                             <td bgcolor="#FFFFFF" style="background-color: rgb(255, 255, 255); padding: 18px 24px 28px;">
                                 <table role="presentation" border="0" cellspacing="0" cellpadding="0" width="100%" style="width: 100%; min-width: 100%;">
                                     <tbody> <tr> <td align="left" valign="middle">
                                        $(body)
                                        <br/>
                                        <br/>Thanks.
                                     </td></tr></tbody>
                                 </table>
                             </td>
                         </tr>
                     </tbody>
             </table>
             </center>
         </td>
     </tr>
    </tbody>
</table>

Use the environment variable in the plugin

In the Message Body Template field, use the following syntax to call the environment variable template:

#envVariable.template#

You can now dynamically populate the $(body) content when sending the email.

In this article, you are using the environment variable to store the email template, but you can retrieve it anywhere else using other hash variables.

Use form-based templates (optional)

If you prefer, store your template in a specific form row (Record ID = 0) from the table named setup. You can retrieve the template using the following Form Binder Hash Variable syntax:

#form.setup.template[0]?noescape#

By using noescape, the template will render as intended without escaping any special characters. 

See more about Escaping the Resultant Hash Variable.

With this plugin, we can now modify the template without needing to modify every email tool.

Download plugin

Created by Julieth Last modified by Aadrian on Nov 19, 2024