Skip to Content

There are 3 approaches to send mail(s) from a dashboard.

Approach – 1 – Send an alert mail from a dashboard (Automatic/manual)

Approach – 2 – Send a mail with a single attachment from a dashboard (Automatic/manual)

Approach – 3 – Send a mail with multiple attachments from a dashboard (Automatic/manual)

In this blog, we will talk about Approach-1.

1. Abstract:

Automatic email notification has become a standard method for communicating in today’s world. Xcelsius Dashboard does not have in-built automatic email notification functionality. Dashboards are made to view information at glance as pictorial view. It always fetches live data. Sometimes there are some critical situations in which if email is triggered immediately can solve problem.

Solution provided here can send simple mails as well as with attachment to any number of recipients.

2. How to develop SEND MAIL functionality in Dashboard:

–      Install Tomcat server.

–     Download mail.jar file.

–     Put files in specific folder.

          1) Place mail.jar file into D:\apache-tomcat-6.0.39\lib

          2) Place two files converToXml.jsp and sendmail.jsp into D:\apache-tomcat-6.0.39\webapps\ROOT

                                ConverToXml.jsp – To convert data of embedded excel sheet of dashboard to XML file

                                Sendmail.jsp  – To send mail using some java API
–    
Make XML DATA connection in Dashboard to convert EXCEL data to XML file.

/wp-content/uploads/2014/09/1_532701.jpg

1) Provide name of connection (eg.EXCEL to XML)

2) Give path of your file in tomcat server.

      http://localhost:8080/converToXml.jsp

3) Change MIME type to application/x-www-form-urlencoded

4) Give information for creating xml file.

                                – Check Enable Send checkbox

                                – Give name of file to be created (eg.mailinfo)

                                – Select range of data (for eg. Sheet1!$B$2:$B$5)

/wp-content/uploads/2014/09/2_532712.jpg

3.   Make XML DATA connection in Dashboard to send mail:

/wp-content/uploads/2014/09/3_532714.jpg

1)  Provide name of connection (eg.Send Mail)

2)  Give path of your file in tomcat server.

      http://localhost:8080/sendmail.jsp

3) Change MIME type to application/x-www-form-urlencoded


4.     Put one refresh button on canvas and set properties as below:

/wp-content/uploads/2014/09/4_532715.jpg

ConvertToXml.jsp

<%@page contentType=”text/html” pageEncoding=”UTF-8″%> <%@page import=”java.io.*” %> <% // Set the path to save scenarios   

String scenarioPath = request.getRealPath(“/”) ;    

// Build a string from the input 

    InputStream in = request.getInputStream();

    BufferedReader r = new BufferedReader(new InputStreamReader(in));

    StringBuffer buf = new StringBuffer();

    String line;

    while ((line = r.readLine())!=null)

                {        

                buf.append(line);        

                } 

    String xmlString = buf.toString();

// Write this to an xml file

    int startPos = xmlString.indexOf(“variable name=”) + 15;

    int endPos = xmlString.indexOf(“\”>”);

    String fileName = xmlString.substring(startPos, endPos);

    PrintWriter fileWriter = new PrintWriter (new BufferedWriter(new FileWriter(scenarioPath + fileName + “.xml”)));

    fileWriter.write(xmlString);

    fileWriter.flush();

    fileWriter.close();

%>


This code generate mailinfo.xml file in the root folder.


Sendmail.jsp


Find out the code from google to send mail and write down the same in this sendmail.jsp file. Also add the code for parsing mailinfo.xml.


5.   How to use SEND MAIL functionality in Dashboard:

Start tomcat server.Go to the apache tomcat bin directory and click on start.bat

  Run dashboard and click on send button. This is manual sending of mail. If you want to send alert mails automatic, you can set timing in XML connections of dashboard.

Regards,

Zalak Dalal

To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply