Solved

mailto: extendability

Posted on 2000-04-20
15
217 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
HTML table 7 54
Image decoding from Camera 3 42
Mobile version of website does not react 6 49
Bootstrap input box width 2 13
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…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

708 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

15 Experts available now in Live!

Get 1:1 Help Now