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
Solved

Send EMail using javascript?

Posted on 2000-05-13
6
1,026 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
  • 4
  • 2
6 Comments
 
LVL 3

Accepted Solution

by:
fibdev earned 200 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

837 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