Typical emails from bots look boring and don't have a professional look. To generate professional looking emails, developers need to write code to take the data model and apply the data to the template to generate the HTML markup.

Our deep knowledge in C# & allowed us to think differently and use Razor engine to do the heavy lifting of rendering the template and at the same time apply complex logic to bind the data to the template.

What it does

Razor email activity generates robust Html markup by combining a Razor template and applying the data model.

This activity takes a CSHTML template written in Razor syntax and a data model object and generates the HTML markup which can be used to send emails.

How we built it

Microsoft introduced Razor view engine as part of ASP.NET MVC 3 for server side rendering of Html views. The ASP.NET team implemented the Razor parser independent from ASP.NET which gives the user the liberty to use it outside of web applications to generate any type of document including HTML emails.

This activity is built using RazorEngine, A templating engine built on Microsoft's Razor parsing engine. RazorEngine allows you to use Razor syntax to build dynamic templates. & C# utilizing Razor syntax.

The Razor syntax is a template markup syntax, based on the C# programming language, that enables the programmer to use an HTML construction workflow to build robust professional looking templates. enter image description here

@model dynamic
<!DOCTYPE html>
<html lang="en" xmlns="">
    <div class="table-content">
        <table class="inner-table">
            @for (var i = 0; i < Model.FileDetails.Count; i++)
                    @if (@Model.FileDetails[i].Status == "Pass")
                        <td style="background-color: #70ad47;">@Model.FileDetails[i].Status</td>
                        <td style="background-color: #ff0000;">@Model.FileDetails[i].Status</td>

enter image description here

Advantages of Razor

  • Ability to use strongly typed or anonymous models
  • Conditional statements/Loops
  • Access to full features of C#/.Net
  • Clean Razor syntax and IntelliSense

Refer to this documentation to understand more about Razor syntax to build advanced & robust templates.

Challenges we ran into

We faced challenges during integration of xaml code of activity with UIPath.

Accomplishments that we're proud of

Allows users to generate professional looking emails with no coding

What we learned

We learn following things:

  1. UIPath
  2. UIPath activity implementation
  3. Razor engine details
  4. How Razor Engine transform Razor template to Final HTML document.
  5. Difference between RazorEngine and RazorViewEngine

What's next for Razor Email Template Activity

Add additional features to support additional use cases

Built With

Share this project: