594
Views
5
Comments
Customize Email body

I am using traditional web application for sending emails. This application is being consumed by some other module that is passing email_body as a parameter.

If we use expression for displaying email_body, it is rendered as it is in email.

However,  email body has data specific to each user to which mail would be sent, which needs to be replaced while creating mail. 


Below is what is passed as email_body from main module:

<h1>Hello {UserName}</h1>

<p>Welcome to Outsystems. We need to confirm your email address {Email_address}</p>


How to replace that user specific data in expression

2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Rakhi,

As a solution for the mentioned use-case, you can introduce two input parameter to the Email Template, let's say Username and UserEmail then refer the input parameter value within the expression as shown below...


"<h1>Hello "+ EncodeHtml(Username) + "</h1>
<p>Welcome to Outsystems. We need to confirm your email address " + EncodeHtml(UserEmail) +"</p>"

Hope this helps you!


Regards,

Benjith Sam

2025-10-09 15-40-22
Craig St Jean
Staff

Hello Rakhi,

You have a few options.  If your text is static then Benjith's suggestion will work just fine.  If your text is dynamic, e.g. stored in a database, then you can either use Regex_Replace in the Text module, or you can import a .NET template engine.

If you use Regex_Replace, it will be a very basic replace and you will have to ensure you properly escape regex characters.  I've included a simple example on what you could use.  In this case, you can call it like this:

For anything more complex, I would suggest a .NET template engine.

EDIT: I didn't do it in my sample, but if you know the output is HTML then you should use EncodeHtml in the Regex_Replace, similar to Benjith

SimpleTemplateCS.oml
UserImage.jpg
Rakhi Gupta

Craig St.Jean wrote:

Hello Rakhi,

You have a few options.  If your text is static then Benjith's suggestion will work just fine.  If your text is dynamic, e.g. stored in a database, then you can either use Regex_Replace in the Text module, or you can import a .NET template engine.

If you use Regex_Replace, it will be a very basic replace and you will have to ensure you properly escape regex characters.  I've included a simple example on what you could use.  In this case, you can call it like this:

For anything more complex, I would suggest a .NET template engine.

EDIT: I didn't do it in my sample, but if you know the output is HTML then you should use EncodeHtml in the Regex_Replace, similar to Benjith

 

 Thank you. Was trying to use both static text and one retrieving from database. 

This solution worked!! Thanks

2017-07-15 18-41-36
Sachin Mahawar

Hi Rakhi,

Since this is an exact search you can take the expression in a variable and can use Outsystems's in build Replace() function to replace the user-specific information.

Thanks,

Sachin

UserImage.jpg
Rakhi Gupta

Sachin Mahawar wrote:

Hi Rakhi,

Since this is an exact search you can take the expression in a variable and can use Outsystems's in build Replace() function to replace the user-specific information.

Thanks,

Sachin

 

 Thank you. It worked. 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.