Solved

mailto: extendability

Posted on 2000-04-20
15
223 Views
Last Modified: 2010-04-09
I'm trying to figure out how (or if) I can get a mailto: link to automatically insert some starter text into the mail message. Has anyone come across a way to do this?

Thanks
0
Comment
Question by:winkle
15 Comments
 
LVL 3

Expert Comment

by:fibdev
ID: 2736565
You can use javascript to do this ...  This will fill in the subject, but I don't know about filling in the message body.

<SCRIPT language="JavaScript">
<!--
/* Mailto enhancement */

function e_friend()
{
var e_add= 'you@youraddy.com';
var subj= 'your subject here';
var e_body= 'enter some text here';
if ((subj==" ") || (subj==null))
 subj="Hi!";
window.location="mailto:"+e_add+"?subject="+subj;}
//-->
</SCRIPT>

Use this as the link:
<A HREF="javascript:e_friend2()">Email</A>


This may work too ...
<a href="mailto:you@youraddy.com?subject='your subject'">mail me!</a>
0
 
LVL 3

Expert Comment

by:fibdev
ID: 2736578
Nevermind that last one, I had to fix something on it ...

Revised:

<SCRIPT language="JavaScript">
<!--
/* Mailto enhancement */

function e_friend()
{
var e_add= 'you@youraddy.com';
var subj= 'your subject here';
if ((subj==" ") || (subj==null))
 subj="Hi!";
window.location="mailto:"+e_add+"?subject="+subj;}
//-->
</SCRIPT>

Use this as the link:
<A HREF="javascript:e_friend()">Email</A>
0
 
LVL 1

Expert Comment

by:lambda
ID: 2737003
<a href="mailto:me@mydomain.com?subject=hello&body=what is this">Mail me</a>

£.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2737152
Or use the CDONTS object from ASP (that is IF you can use ASP)
0
 

Expert Comment

by:Tarraq
ID: 2737184
Hey!

lambda's answer is the easiest, but please note, that this won't work with all browsers / mail clients.

- Tarraq
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2737327
lease note that you won't be able to have a subject with spaces.
0
 
LVL 3

Accepted Solution

by:
fibdev earned 50 total points
ID: 2738769
See if this one lets you include message text ...

<SCRIPT language="JavaScript">
<!--
/* Mailto enhancement - Place this in the head of the document */

function e_friend()
{
var e_add= 'you@youraddy.com';
var subj= 'your subject here';
var e_body= 'message text goes here ...';
window.location="mailto:"+e_add+"?subject="+subj+"&body= "+e_body;}
//-->
</SCRIPT>

Use this as the link:
<A HREF="javascript:e_friend()">Email</A>

This will produce the results you want.  Just reject it if you want to try another way, but the only way I think your going to have spaces in the message subject and body is to use some sort of scripting.

:)
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: 2738777
There is a space before the message body ... try replacing this line:

window.location="mailto:"+e_add+"?subject="+subj+"&body= "+e_body;}


with this one ...

window.location="mailto:"+e_add+"?subject="+subj+"&body="+e_body;}


:)
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2739576
You might wanna use the replace function to replace the body text etc with %20 (which is supposed to be a space)
0
 
LVL 3

Expert Comment

by:fibdev
ID: 2739759
CJ,

I tryed it like this ...

<SCRIPT language="JavaScript">
<!--
/* Mailto enhancement - Place this in the head of the document */

function e_friend()
{
var e_add= 'you@youraddy.com';
var subj= 'your subject here';
var e_body= 'message text goes here ...';
window.location="mailto:"+e_add+"?subject="+subj+"&body="+e_body;}
//-->
</SCRIPT>


It works good.  As of yesterday I'm using it on my site for people to unsubscribe to my mailing list.  It's funny, but this isn't the first thing I've coded becuase the idea was spawned here at the ee.  Many thanks to the Experts-Exchange.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2739764
quote:
This will produce the results you want.  Just reject it if you want to try another way, but the only way I think your going to have spaces in the message subject and body is to use some sort of scripting.

quote:
It works good.  As of yesterday I'm using it on my site for people to unsubscribe to my mailing list.  It's funny, but this isn't the first thing I've coded becuase the idea was spawned here at the ee.  Many thanks to the Experts-Exchange.

And you tested it with spaces and stuff too?????.......uhm......whichn of your comment is true?

0
 
LVL 3

Expert Comment

by:fibdev
ID: 2739775
uh ...

I don't know what your asking but you can go to my site and click the link to be removed from the mailing list at the bottom of the products page

http://fibdev.com/products.htm#produpmail

Just click where it says "Click here" in the blue box.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2739782
Just checked it, you're right.
0
 
LVL 3

Expert Comment

by:fibdev
ID: 2747543
waiting ...  :)
0
 

Author Comment

by:winkle
ID: 2757833
Thanks. Both methods worked very well. (spaces included)
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

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

895 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

14 Experts available now in Live!

Get 1:1 Help Now