Solved

Send EMail using javascript?

Posted on 2000-05-13
6
1,012 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now