Send EMail using javascript?

User can click following link:
<a href="mailto:person@domain.com&subject=This is only a test">Click here to send email</a>
to send a mail with reciever and subject filled. The user must fills the body.

Is it possible to send mail in a HTML page with reciver, subject and body all filled? Just bringup a window, user can change everything.

JavaScript can do it?
I don't like java applet.
qdyoungAsked:
Who is Participating?
 
fibdevConnect With a Mentor Commented:
Here you go:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<SCRIPT language="JavaScript">
<!--
/* Mailto enhancement by: Fibdev Software, Inc. */
function Advanced_email()
{
var e_add= 'your@address.here';
var subj= 'Your message Subject';
var e_body= 'Some message text here';
window.location="mailto:"+e_add+"?subject="+subj+"&body="+e_body;}
//-->
</SCRIPT>
</head>

<body>
<input type="button" value="E-Mail" OnClick="javascript:Advanced_email()">
</body>

</html>
0
 
fibdevCommented:
Or, if you just want a link and not a button:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<SCRIPT language="JavaScript">
<!--
/* Mailto enhancement by: Fibdev Software, Inc. */
function Advanced_email()
{
var e_add= 'your@address.here';
var subj= 'Your message Subject';
var e_body= 'Some message text here';
window.location="mailto:"+e_add+"?subject="+subj+"&body="+e_body;}
//-->
</SCRIPT>
</head>

<body>
<a href="javascript:Advanced_email()">E-Mail</a>
</body>

</html>
0
 
qdyoungAuthor Commented:
Thanks.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
fibdevCommented:
No problem,  I had the script laying around from someone else asking the same question :)  It only took me a couple of minutes to write it.
0
 
qdyoungAuthor Commented:
If there is line break in e_body, what characters should I use to stand for  line break?

I have tried
%0D%0A
\r\n
\n\r
\r
\n
, but they don't work.

Sorry for bothering you again.
0
 
fibdevCommented:
Really it's no bother.

I've been trying to work around this, but so far I haven't been able to make it work.  I'm not saying it isn't possible, but here's the thing.  That javascript just provides a way to do the same thing that can be done with a hyperlink.  The only thing is, with a hyperlink, your subject and body can't have spaces, it has to be a single string of charictors.  That script just provides a way of placing spaces into the strings.  No matter what the script tries to do, it's at the mercy of the browser and the email program running it.  That's why I don't know if there is a way to place line breaks into it or not.  I don't have the points to do it myself, but if it means a lot to you to have this format.  I would take the script to the javascript section of Experts-Exchange and offer up a few points to see if someone can modify it for you to suit your needs.  Please let me know if someone is able to do this for you.

Gabe
expert@fibdev.com
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.