Daniel Langenhan

IT Consulting and Architecture for Automation and Cloud

CoolMail

This package enables vRealize Orchestratior (vRO) to send HTML formatted emails via SMTP.

Version

VersionDateChange
2.012.11.18Pre-requisite Checker
1.120.12.17Added debug and Optional fromName and fromMail
1.021.09.17
Initial Web published version
0.x06.03.16Initial version with CookBook


Highlights

  • Use preformatted HTML or plaintext email Templates
  • Easy to use
  • Replace {tags} in the Mail template with vRO values
  • Repeats HTML structures and fills them either with values from arrays or from properties.
  • Use a configuration to centrally store your mail settings

Description

The coolMail subsystem works by substituting a tag with an vRO value. A coolMail tag can be freely defined and must have { } winged brackets around it. For example {vm.name} or {userName}.

The User just prepares a HTML template (e.g. using html-online.com) and inserts tags where later values from vRO should be displayed. This enables one for example to create very nice looking HTML email that can be used with vRealize Automation (vRA).


Varibales

The input to CoolMail is a property which is defined as: 


Property Key Name

Type

Required

mailTo
string (multiple Email addresses with comma speration)yes
mailCC
string (multiple Email addresses with comma speration)
no
mailBCC
string (multiple Email addresses with comma speration)
no

subject

String (can contain {tags} )

yes

mailTemplate

Resource Element

yes

fromMail

Sting

no

fromName

Sting

no

mailReplacements

Property Key Name

Type

Required

subName

subValue

yes

 

subValue:

  • String
  • Array of String
  • Property (Strings)

no


The variable subject can also contain {tags} to be replaced.

HowTo

Installation and configuration

  1. Import the vRO package into your vRO appliance
  2. Run the workflow configure CoolMail

The configuration program will ask for all the required information to establish a SMTP connection between vRO and a Mail server. The configuration is saved in a Configuration file and a test email can be sent to check if the SMTP configuration is working.

All configurations are stored in Configurations: vleet | coolmail.conf

The example will ask for your name, some other input as well as an array of Strings. It will then use an example mail template to send an email.

Basic Usage

1.       Create a HTML email template (see example beneath)

<html>
this is a test {vm.name}.
<table>
<tr><td>Name</td><td>{vm.name}</td></tr>
<tr><td>IP</td><td>{vm.ip}</td></tr>
<tr><td>Mac</td><td>{vm.mac}</td></tr>
</table>
</html>

    2.       Save the HTML email as a text file and upload it into vRO as an resource element

3.       Create a new workflow

4.       Add the coolMail Subsystem workflow

5.       Create an attribute of type ResoruceElement and link it to the mail template you have uploaded

6.       Use a Scriptable task with an OUT-attribute of type Properties, called mailPayload.

7.       In the scriptable task define the mailPayload (see example beneath)

var mailPayload= new Properties();
mailPayload.put("mailTo","info@langenhan.info");
mailPayload.put("subject","Test email für {vm.name}");
mailPayload.put("mailTemplate",resourceElement);
var mailReplacements= new Properties();
mailReplacements.put("vm.name","myVM");
mailReplacements.put("vm.ip","192.168.220.10");
mailReplacements.put("vm.mac"," 0A:0B:0C:0D:0E:0F");
mailPayload.put("mailReplacements",mailReplacements);

8.       Pass the mailPayload to the coolMail Subsystem workflow

8.       Run the workflow

Repeat lines

You can use arrays or properties to repeat HTML code. You need to encase the structure you would like to repeat with the  HTML comment
<!--{TAG.start}--> and <!--{TAG.end} -->
where TAG is the replacement tag name you want to use.

For Arrays you can use {TAG.counter} to display the counter (starting at 0) and {TAG.value} will contain the value of the array for the given counter. If you use {TAG.counter1} instead the counting will start at 1. Mixing the Tags will result in nonsence output.

For Properties you can use {TAG.name} to display the Property key and {TAG.value} to display the Property value of a given key. Both Tags must be strings.

Examples:

 

Array

Properties

HTML Source Code

<!--{repeat.start}-->
<tr>
<td>{repeat.counter}</td>
<td>{repeat.value}</td>
</tr>
<!--{repeat.end}-->

<!--{plugins.start}-->
<tr>
<td>{plugins.name}</td>
<td>{plugins.value}</td>
</tr>
<!--{plugins.end}-->

vRO code

var repeatArray=new Array();
repeatArray.push("VM 1");
repeatArray.push("VM 2");
repeatArray.push("VM 3");
mailReplacements.put("repeat",repeatArray);

var propertyValues=new Properties();
propertyValues.put(“VM 1”,”vCenter”);
propertyValues.put(“VM 2”,”vRO”);
propertyValues.put(“VM 3”,”vRA”);
mailReplacements.put("plugins",propertyValues);

HTML output

<tr>
<td>0</td>
<td>VM 1</td>
</tr>
<tr>
<td>1</td>
<td> VM 2</td>
</tr>
<tr>
<td>2</td>
<td> VM 3</td>
</tr>

<tr>
<td>VM 1</td>
<td>vCenter</td>
</tr>
<tr>
<td>VM 2</td>
<td>vRO</td>
</tr>
<tr>
<td>VM 3</td>
<td>vRA</td>
</tr>

Replace images

You can also use Cool mail to replace images. You do that by exchanging the content of the HTML <img> tag with a image location.

HTML Source Code

<img src="{ImageSource}" />

vRO code

mailReplacements.put("ImageSource",”http://langenhan.info/images/object0.png”);

HTML output

<img src="http://langenhan.info/images/object0.png" />

Package content

This Package contains three workflows:

  • The CoolMail Subsystem workflow
  • The CoolMail configuration workflow
  • and an example workflow

Dowload Links:

The following Software is distributed under the GNU General Public License, which allows you to use, copy, modify and distribute (keeping my name as Author). If you modify the programm,please let me know and share your ideas. 

TheSoftware is written for vRealize Ochrestrator and works with Version 5.5 or better

Download vRealize Orchestrator Package