Saturday, June 1, 2013

How to send email using javascript?

JavaScript is of course client based so doesn't have the capabilities as say C# on the server. To send email, without calling some server-side code, you are basically limited to mailto


You can redirect to a mailto:someone@example.com?cc=someone_else@example.com&subject=This%20is%20the%20subject&body=This%20is%20the%20body address which tells the browser to fire up the mail client which then makes the mail ready to send - the user just has to hit "submit".
Code:
document.location="mailto:someone@example.com?cc=someone_else@example.com&"+
    "subject=This%20is%20the%20subject&body=This%20is%20the%20body";

0 Ads:

Post a Comment