A quick note: Sorry if it looks a bit crazy around here. I’m in the middle of tearing down my old theme and building a new one. In the meantime, you can watch me go through this very public process. (ha)
A standard mailto link in your e-mail or on your website causes the default e-mail program on the computer to open and create a new message. But what if the user uses Gmail instead? This causes a situation where the default mail client then has to be closed and a copy-paste operation has to be performed to get the desired result.
But what if you could have it both ways? What if you could give your readers the option of choosing to open the mail link in Gmail or their default mail client?
The Standard E-Mail Link
The usual e-mail link looks like this:
<a href=”mailto:firstname.lastname@example.org”>E-mail me!</a>
What this says is to compose a new e-mail and put "email@example.com" into the To: field.
Adding Additional Information
Did you know you can also make an e-mail link include a subject and some text in the body of the e-mail? But first you need to encode the information to work in an e-mail link. First, decide what you want to put into these fields. For this example, we’ll use:
Subject: Look here!
Body: Link – http://mysite.com/checkitout
Now we’ll take these pieces of info and encode them (one at a time) on this site. We’re now left with:
Now we can put it all together in one line of HTML:
<a href=”mailto:firstname.lastname@example.org?body=Link%20-%20http%3A%2F%2Fmysite.com%2Fcheckitout&subject=Look%20here!”>Send to a friend</a>
Offering a Gmail Link
Now that you have created the info you need, you can now make a Gmail link. It looks like this:
<a href=”https://mail.google.com/mail/?view=cm&fs=1&tf=1&body=Link%20-%20http%3A%2F%2Fmysite.com%2Fcheckitout&su=Look%20here!”>Send to a friend via Gmail</a>
But I Can’t Deal With Code!
No worries. You can insert a standard link in the WordPress editor and paste all of your href code between the quotation marks like this:
Feel free to ask in the comments below!