Support Overview

Tutorials

Usage Examples

Upgrade Information

FAQ

New Release History

You are here:   Visualware >   MyConnection Server >   Support >   Usage Examples >   Passing results to an email link

Passing results to an email link

The example below produces an email link once the test has finished. It will appear below the applet. When clicked it will launch a new email (using whichever email application has been set as default) that includes various test results.

Code Required

The code below just needs to be copied into a web page at the position the applet is to appear. The only change that will be needed is the codebase, highligted in red below. This should be changed to the address of your MyConnection Server installation.

NOTE: The last param tag has been truncated to fit this page, make sure this line is whole once pasted.

<applet mayscript name="mcs" code="myspeedserver/applet/myspeed.class" archive="/myspeed/myspeed_s_8.jar,/myspeed/plugins_s_8.jar" codebase="http://mcsiad.visualware.com/myspeed" width=600 height=400>
<param name="testspecid" value="-2">
<param name="permissions" value="all-permissions">
<param name="js" value="passResults($MSSID$,$DETAILLINK$,$SPEED.DSPEED$,$SPEED.USPEED$,$SPEED.QOS$,$SPEED.UQOS$,$SPEED.RTT$,
$SPEED.AVGRTT$,$SPEED.RTTCONSISTENCY$,$SPEED.MAXPAUSE$,$SPEED.BANDWIDTH$,$SPEED.ROUTESPEED$,$SPEED.FORCEDIDLE$)">
</applet>

<br><br>

<div id="theemaillink" style="display:none;"></div>

Copy and paste the entire code below into the opening <head></head> section of your page. The code is commented to explain what is going on at each stage.

The URL in BLUE below will also require changing to the correct MyConnection Server installation.

<script type="text/javascript">

// Function called when the test has completed
function passResults(mssid,detaillink,downspeed,upspeed,downqos,upqos,minrtt,avgrtt,rttconsistency,maxdelay,bandwidth,routespeed,forcedidle) {

downToKbps = addCommas(Math.round(downspeed/1000)); <!-- Converts the download speed to Kbps, rounds the number, then adds commas -->
upToKbps = addCommas(Math.round(upspeed/1000)); <!-- Converts the upload speed to Kbps, rounds the number, then adds commas -->
bwToKbps = addCommas(Math.round(bandwidth/1000)); <!-- Converts the bandwidth to Kbps, rounds the number, then adds commas -->
rtToKbps = addCommas(Math.round(routespeed/1000)); <!-- Converts the routespeed to Kbps, rounds the number, then adds commas -->

bodyPct = escape("%");
bodyQues = escape("?");

// Creates the email body to be used in the MailTo link
var emailbody = "";

emailbody += "Enter some details here about the problem you are having....";
emailbody += "%0D%0D";
emailbody += "Speed Test Results";
emailbody += "%0D%0D";
emailbody += "MSSID:" + mssid + "%0D";
emailbody += "http://mcsiad.visualware.com/myspeed/db/report" + bodyQues + "id=" + mssid + "%0D";
emailbody += "Download Speed: " + downToKbps + " Kbps %0D";
emailbody += "Upload Speed: " + upToKbps + " Kbps %0D";
emailbody += "Download Consistency of Service: " + downqos + bodyPct + " %0D";
emailbody += "Upload Consistency of Service: " + upqos + bodyPct + " %0D";
emailbody += "Min RTT: " + minrtt + "ms %0D";
emailbody += "Avg RTT: " + avgrtt + "ms %0D";
emailbody += "RTT Consistency: " + rttconsistency + bodyPct + " %0D";
emailbody += "Max Pause: " + maxdelay + "ms %0D";
emailbody += "Bandwidth: " + bwToKbps + " Kbps %0D";
emailbody += "Route Speed: " + rtToKbps + " Kbps %0D";
emailbody += "Forced Idle: " + forcedidle + bodyPct + " %0D";

// Populates in innerHTML with the mailto link, which includes the MSSID in the subject line and the email body above as the body
document.getElementById("theemaillink").innerHTML = '<br><br><a href="mailto:someone@company.com&amp;subject=Speed Test: ' + mssid + '&amp;body=' + emailbody + '">Click here to email support for test ID: ' + mssid + '</a>';

// Makes the DIV visible
document.getElementById("theemaillink").style.display = 'block';
}

// Function used to add commas
function addCommas(str){

var arr,int,dec;
str += '';

arr = str.split('.');
int = arr[0] + '';
dec = arr.length>1?'.'+arr[1]:'';

return int.replace(/(\d)(?=(\d{3})+$)/g,"$1,") + dec;
}
</script>


 

MyConnection Server

Home
Online Testing Portal
Download
Purchase
Resources
Support

Visualware Products

VisualRoute
eMailTrackerPro
Visual IP Trace

   

© Visualware Inc. 2014 - All Rights Reserved