?
Solved

embedding a hyperlink inside a mailto reference

Posted on 2008-11-13
15
Medium Priority
?
1,652 Views
Last Modified: 2012-05-05
Is it possible to include a hyperlink inside the body reference of a mailto call in html?

For example, using the following example:
<a href="mailto:test@somewhere?body=Test body">email with default body</a>

Is it possible to change the "Test Body" reference to be a link to www.google.com?

Thanks
0
Comment
Question by:dj88
  • 7
  • 5
  • 2
  • +1
15 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 22952341
You need to encode the value:
email with default body
0
 
LVL 82

Expert Comment

by:hielo
ID: 22952375
this will help you encode your data:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
<title></title>
</head>
<body>
<form>
	<div>Type Raw value then click in "Encoded Value"</div>
	<div>"Raw" Value: <textarea name="raw" onchange="encoded.value=encodeURIComponent(this.value)" rows="10" cols="80" ></textarea></div>
	<div>Encoded Value: <textarea name="encoded" rows="10" cols="80"></textarea></div>
</form>
</body>
</html>

Open in new window

0
 
LVL 15

Expert Comment

by:ncoo
ID: 22952404

As HTML
 
<a href="mailto:test@somewhere?body=Test body&lt;a href='http://google.com'&gt;google&lt;/a&gt;">email with default body</a>
 
AS TEXT
<a href="mailto:test@somewhere?body=Test body http://google.com">email with default body</a>

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 15

Expert Comment

by:ncoo
ID: 22952423
Sorry you wanted Test Body replaced, here you go:
As HTML
 
<a href="mailto:test@somewhere?body=&lt;a href='http://google.com'&gt;google&lt;/a&gt;">email with default body</a>
 
AS TEXT
<a href="mailto:test@somewhere?body=http://google.com">email with default body</a>

Open in new window

0
 
LVL 10

Author Comment

by:dj88
ID: 22955184
Thanks for the responses...

In both cases, I get the following results in the body of the email.  Is there anyway to actually just put the hyperlink in the body rather than the HTML?

<a href="http://www.google.com">google</a>

Am I doing something wrong?
0
 
LVL 82

Expert Comment

by:hielo
ID: 22955255
I didn't realize my original post got mangled! Take my second post, save it as encoder.html

then in the top text area type the body of whatever you want on the body. Then click on the lower text area and copy the result from the lower textarea and put that as the value of the "body". So if you were to type
http://www.google.com/
 
the result will be:
<a href="mailto:test@somewhere?body=http%3A%2F%2Fwww.google.com%2F">email with default body</a>
 
which is what you need.

Open in new window

0
 
LVL 82

Expert Comment

by:hielo
ID: 22955273
>>the result will be:
I meant:
 ... the result will be http%3A%2F%2Fwww.google.com%2F

so on your original post:
<a href="mailto:test@somewhere?body=Test body">email with default body</a>

you need to assign that result to body:
<a href="mailto:test@somewhere?body=http%3A%2F%2Fwww.google.com%2F">email with default body</a>
0
 
LVL 10

Author Comment

by:dj88
ID: 22955311
That's a little closer - However, I want it the body of the email to say:

Google (or whatever)

but link to http://www.google.com

So, is it possible to edit the name of the link so to speak?
0
 
LVL 82

Expert Comment

by:hielo
ID: 22955407
Then in the top text area you need to type:
<a href="http://www.google.com/">Google</a>
 
and the result that you get in the lower textarea you assign it to "body"

Open in new window

0
 
LVL 82

Expert Comment

by:hielo
ID: 22955414

<a href="mailto:test@somewhere?body=%3Ca%20href%3D%22http%3A%2F%2Fwww.google.com%2F%22%3EGoogle%3C%2Fa%3E">email with default body</a>

Open in new window

0
 
LVL 10

Author Comment

by:dj88
ID: 22955553
Maybe I'm doing something wrong - but that give me the following in the body of the email:

<a href="http://www.google.com/">Google</a>
0
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 22955671
>>Maybe I'm doing something wrong - but that give me the following in the body of the email:
Yes, that is what I was expecting, but I see what you are trying to do. As far as I know, there is no "flag" to specify that you are interested in composing an html email. To clafy, there is the:
body,subject,cc, etc, "flags" but there is not "format=mail" type of flag. The closest you will get is what you are already doing, and hope that the email client of the user "deciphers" that line and interprets it as an HTML email.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 22955982
All credit to Hielo for this but I noticed this Q and was following it.  His last post is correct that you will be at the mercy of the email client (i.e. the user's email software).  I don't know any that would reliably interpret the code as you want.  Hielo did provide the way to send it to the mailer if it would work but most will just treat what is in "body" as a text email.  All credit to Hielo for that and I just wanted to confirm.
I really suggest you consider using server side script instead for handling mailing.  Mailto is a poor option in my opinion for MANY reasons.  In this case a server script could make the email just as you want and you would get your result.  You would also have the benefit of a method that doesn't rely on the client's email program, doesn't expose your email address to bots/spiders, and is more professional.  Almost all server side languages have an easy way to send emails so making a script to do this (or finding one online) is easy and basic.  The only requirement is a server side language/techonology and some mail "object" or class.
If you have a question about what I have said let me know.  Please keep in mind the last part is a little beyond what you asked here, which Hielo seems to have answered. :)
bol
0
 
LVL 10

Author Comment

by:dj88
ID: 22956982
I appreciate all the comments and suggestions...
0
 
LVL 10

Author Closing Comment

by:dj88
ID: 31516481
Thanks for the help...
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

850 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