Software - Cool Mail

This Package will enable Aria Orchestrator to send HTML emails based on a template with exchangeable variables.
Aria Orchestrator is owned and licenced by VMware.

UPDATED VERSION 5.0 (27/02/24)

Features

  • 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 store your mail settings centrally

  • can use attachment

The coolMail subsystem works by exchanging a tag in the preformatted HTML body with an Orchestrator variable. The name of a tag can be freely defined but must be enclosed by { } winged brackets. For example, {vm.name} or {userName}.

You can easily create an HTML template by using a free online HTML WYSIWYG editor like html-online.com.

 Installation and configuration

  1. Import the vRO package into your vRO appliance

  2. Run the workflow configure CoolMail

  3. Send test email

The workflow facilitates the setup of SMTP connections between Aria Orchestrator and a mail server on your website. Configuration details are stored in
coolTools | coolmailConf. Users input the required information, and the system tests the SMTP setup by sending a sample email using a predefined template.

Basic Usage

  • Create an 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>

  • Save the HTML email as a text file and upload it into vRO as a resource element

  • Create a new workflow

  • Add the coolMail Subsystem workflow

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

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

  • 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);

  • Pass the mailPayload to the coolMail Subsystem workflow

  • 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 nonsense output.

For Properties (with Strings), 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.

For Properties (with properties), you can use much more complex tables. (please see the example below as weel as the Example Email in the package)

Examples:

 

Array

Properties (String) Properties (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}-->

<!--{vms.start}-->
<tr>
<td>{vms.name}</td>
<td>{vms.os}</td>
<td>{vms.mem}</td>
<td>{vms.cpu}</td>
</tr>
<!--{vms.end}--></tbody>

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);

var vms=new Properties();
for each (vcvm in VcPlugin.getAllVirtualMachines()){
var vmInfo = new Properties();
vmInfo.put("vms.name",vcvm.name);
vmInfo.put("vms.os",vcvm.summary.config.guestFullName);
vmInfo.put("vms.mem",vcvm.summary.config.memorySizeMB/1024);
vmInfo.put("vms.cpu",vcvm.config.hardware.numCPU);
vms.put(vcvm.name,vmInfo);
}

mailReplacements.put("vms",vms);

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>

<tr>
<td>VM 1</td>
<td>Microsoft Windows 10 (64-bit)</td>
<td>2.5</td>
<td>2</td>
</tr>
<tr>
<td>VM 2</td>
<td>Other 3.x or later Linux (64-bit)</td>
<td>8</td>
<td>2</td>
</tr>
<tr>
<td>VM 3</td>
<td>Other 3.x Linux (64-bit)</td>
<td>4</td>
<td>2</td>
</tr>

Attachments

To attach an file to an email you simply have to pass the MimeAttachment to CoolMail. You can either upload one by simply adding an MimeAttachment into your Inputs or create one from scratch like this:
Example 1: JSON Attachment:

var attachment = new MimeAttachment();
attachment.content=JSON.stringify(jsonObject);
attachment.name="report.json";
attachment.mimeType="text/plain";

Example 2: convert an ResourceElement:

var attachment = new MimeAttachment();
attachment.content=resourceElement.getContentAsMimeAttachment() ;
attachment.name=resourceElement.name;
attachment.mimeType=resourceElement.mimeType;

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" />

Variables

The input parameter to CoolMail is a property that 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

testing

boolean

no

attachment

MimeAttachment

no

mailReplacements

 

Property Key Name

Type

Required

subName

subValue

yes

 

SubValue:

  • String
  • Array of String
  • Property (Strings)
  • Property (with Properties)

yes

Change Log

Version Date Change
5.0 27/02/24

Major updates and bug fixes. added featured:

  • testing boolean for skipping sending an email bt logging all output
  • complex Properties added
4.0.1 28.11.23 Minor Changes. Clean up file names
4.0 02.07.23 Minor Changes. New Business Name
3.0 28.07.22 converted to 8.x, general cleanup, added attachments
2.0 12.11.18 Pre-requisite Checker
1.1 20.12.17 Added debug and Optional fromName and fromMail
1.0 21.09.17 Initial Web published version
0.x 06.03.16 Initial version with CookBook