We help IT Professionals succeed at work.

mailto code to format email with title of page

rtod2
rtod2 asked
on
I need to code a mailto button that will use the user's default mail program to mail a link to whatever page they are looking at on my Wordpress site at www.frugalmule.com.  Assistance is greatly appreciated.
Comment
Watch Question

Jason C. LevineDon't talk to me.
CERTIFIED EXPERT

Commented:
Mail it to whom?  Mailto needs a target...

Author

Commented:
Whoever they put in?
Jason C. LevineDon't talk to me.
CERTIFIED EXPERT

Commented:
mailto doesn't work that way.  You can do:

<a href="mailto:someaddress@somedomain.com">Click here to send me an email</a>

What you are talking about is some form of sharing thing.  I recommed getting the AddThis plugin:

http://wordpress.org/extend/plugins/addthis/

Commented:
You can do it with javascript, but you might want to repost in the javascript zone for a javascript expert to help you with that.

You need to listen for a blur event on the input field and then put the contents of the input box into the href attribute of the <a> tag.  

It's not THAT difficult, but I can't do it off the top of my head (yet) and I'm logging off for the night.
Commented:
Try this

<label>Email Address: </label>
<input type="text" id="send_email">

<a href="javascript: void(0)" onClick="this.href = 'mailto:' + document.getElementById('send_mail').value + '?subject=Check Out This Link&body=' + document.URL">Click to Send Email</a>

Commented:
Scratch that... try this


<label>Email Address: </label>
<input type="text" id="send_email" onBlur="document.getElementById('email_link').href = 'mailto:' + this.value + '?subject=Check Out This Link&body=' + document.URL; ">

<a href="javascript:void(0)" id="email_link">Click to Send Email</a>

Open in new window

Author

Commented:
gwkg,
Thank you!  That works well here http://www.frugalmule.com/assist-me/ except that it appears to create a form which I can do without.  Also, the title should take the same name as the link except capitals and not spaces (assist-me becomes Assist Me).  The link itself should only state the last part of the URL explicitly (eg. assist-me).  Thank you sir.

Author

Commented:
related question on the way

Commented:
I replied in your follow up, but how are you going to know where to email the link if you don't have an input field for the user to type it in?

Explore More ContentExplore courses, solutions, and other research materials related to this topic.