Solved

Send EMail using javascript?

Posted on 2000-05-13
6
1,000 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

746 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

17 Experts available now in Live!

Get 1:1 Help Now