Login | Register   
RSS Feed
Download our iPhone app
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



Building the Right Environment to Support AI, Machine Learning and Deep Learning

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:
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.
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;

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

Boris Feldman
Comment and Contribute






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



Thanks for your registration, follow us on our social networks to keep up-to-date