Sep 142010

This creates a javascript function which adds a custom mailto to an href or other object like image or DIV. When clicked it will add custom VARS to the BODY of the email. This is cool when you dont want to use a server side FORM to do this. It also lets the user use their email client of choice.

You could add this to an error page for instance, especially for an internal webapp. For public, you might wanna do this another way. My criteria required for me to do this with a non SS solution and also use the clients mail client of choice. Found online at (

Tested in IE6 and FF2. Works fine when going to Outlook 2003.


<script type=”text/javascript”>
function emailForm(){

var daReferrer = document.referrer;
var email = “”;
var errorMsg = “here here here is the error error error error”;
var subject = “Exception Error”;
var body_message = “%0D%0D%0D%0DThank you “+name+” for submitting this error to us. Please tell us in the space above, what you were doing when the error occurred.%0D%0DReferring Page: “+daReferrer+” %0D%0DException Error Message:%0D——————————————-%0D”+errorMsg;

var mailto_link = ‘mailto:’+email+’?subject=’+subject+’&body=’+body_message;

win =,’emailWindow’);
if (win && &&!win.closed) win.close();

<div style=”border:2px solid black;padding:10px;”>
Please <a href=”#” onclick=”emailForm();”>Email Support</a>