While setting up an automation to automatically email out notifications that a particular service has turned critical or a new critical alarm was received is useful, there are other situations where it would be useful to email data from NOC in an adhoc manner.  Sometimes sending the alarm (as an example) is not enough, you would like to provide some other details in the email.  To do this, it would be useful to have the email client open up and automatically and fill in the email with some of the details such as the alarm data.  This blog covers how to create a right-click operation to email one or more alarms.

There have been ways to send emails via java for a long time.   When java 6 was released a new Desktop class was provided that can launch the default browser, email client, as well as opening properly registered files.   For this blog, I will leverage the launching of the email client.

The core of the java script is to get hold of the desktop object:

var desktop = java.awt.Desktop.getDesktop();

then open email:

desktop.mail( uri );

Before we can do that, we need to build the mail message (“uri”).   The basic format of the mail message is email address, a subject and the body of the email.  Other options such as CC are available.  Here is an example of what the “uri” variable should look like:


For a clientscript right-click on an alarm, the script is automatically provided an “alarms” variable, this is an array of all of the alarms selected.  The first step is to walk through the array of alarms via a for loop.   In my example below, I walk through all of the possible alarm fields.  You may want to change that to pull specific fields.

There is also something specific to email, it has challenges with specific characters in the email.   Due to this I opted to use encode() to clean up the email.  There are probably better ways to clean up the email to exclude special characters, but for the purpose of this blog, this works fine.

//declare a carriage return and line feed
var crlf = "%0D%0A"

//The beginning part of the email such as email address and subject
var msg = "mailto:some@here.com?subject=Operations_Center_Email&body="

//for loop to walk through all of the selected alarms
for( var i=0; i<alarms.length; i++ )
        //for loop to walk through all of the fields within a single alarm
        for( p in alarms[i].properties )
                   //concatenate onto the msg variable the field column name p and value and a cr 
		msg+= java.net.URLEncoder.encode(p + "=" + alarms[i][p]) + crlf;

// set up msg, get desktop, call for email client
var uri = java.net.URI( msg );
var desktop = java.awt.Desktop.getDesktop()
desktop.mail( uri )

When you run this as a clientscript right click, the next thing that should happen is that email should open in compose mode (IE: new message), it will be addressed to some@here.com, contain a subject as well as show the individual alarm column names and values in the body of the email message.   You can then edit the email further and hit send.

There are obviously several ways things can be done when leveraging java.   The intent is to provide a example as well as an idea.   Play with it on your Development system.   Any feedback via comments on the blog is appreciated.

– Tobin

0 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 5 (0 votes, average: 0.00 out of 5)
You need to be a registered member to rate this post.

Disclaimer: As with everything else at NetIQ Cool Solutions, this content is definitely not supported by NetIQ, so Customer Support will not be able to help you if it has any adverse effect on your environment.  It just worked for at least one person, and perhaps it will be useful for you too.  Be sure to test in a non-production environment.

Leave a Reply

No Comments
Tobin Isenberg
Nov 15, 2013
10:07 am
Active Directory Authentication Automation Cloud Computing Cloud Security Configuration Customizing Data Breach DirXML Drivers End User Management Identity Manager Importing-Exporting / ICE/ LDIF Intelligent Workload Management IT Security Knowledge Depot LDAP Monitoring Open Enterprise Server Passwords Reporting Secure Access Supported Troubleshooting Workflow