dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Web
Expertise: Intermediate
Oct 14, 1998

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Mailto Subject Changes

It's possible to create mailto links that include a subject line in addition to just the recipient's e-mail address, however, not all e-mail programs support this functionality. That said, to create a new e-mail message with the subject and CC fields filled in you can use a URL formatted like this:
 
mailto:someone@bigcorp.com?subject=Information&cc=anyone@othercompany.com
To get the functionality you're looking for, use JavaScript to assemble a URL like the one above from the user's selections on the form. Then set the window's location property to that URL. If this was a normal URL, the browser would display in the main window. However, because this is a mailto link, a new window is automatically opened for the e-mail message, while the current page remains visible.
 
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function doMail() {
	var subj;
	var gourl;

	email = "someone@bigcorp.com";
	subj = document.forms.mailform.subject.options[document.forms.mailform.subject.selectedIndex].value;
	cc = "anyone@othercompany.com";
	gourl = "mailto:" + email + "?subject=" + subj + "&cc=" + cc;

	window.location = gourl;
}
//-->
</SCRIPT>

</HEAD>
<BODY>
<FORM NAME="mailform">
<SELECT NAME="subject">
	<OPTION VALUE="Info">Information request</OPTION>
	<OPTION VALUE="Tech. Support">Technical support</OPTION>
	<OPTION VALUE="Comments">Comment</OPTION>
</SELECT>
<INPUT TYPE="BUTTON" VALUE="Send Mail" OnClick="doMail()">
</FORM>
</BODY>
</HTML>

Boris Feldman
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date