Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Send EMail using javascript?

Posted on 2000-05-13
6
Medium Priority
?
1,054 Views
Last Modified: 2008-03-10
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.
0
Comment
Question by:qdyoung
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 3

Accepted Solution

by:
fibdev earned 800 total points
ID: 2806950
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
 
LVL 3

Expert Comment

by:fibdev
ID: 2806951
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
 

Author Comment

by:qdyoung
ID: 2807801
Thanks.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:fibdev
ID: 2808227
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
 

Author Comment

by:qdyoung
ID: 2809880
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
 
LVL 3

Expert Comment

by:fibdev
ID: 2812415
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question