With the effect we expect from any email link -
hyperlinked text that fires up a new message window with the recipients email address conveniently filled in already.
Like this one: Mail
me
But the mailto link can be made to work much harder than
that. You can have it add a subject line, send copies
to multiple recipients or even write the entire email
message.
1. Add a Subject Line
You can prefill the subject line in the email by adding the subject preceded by
'?subject=' after the email address.
So the link now becomes:
<a href="mailto:someone@yoursite.com?subject=Mail from Our
Site">Email Us</a>
You can see the effect of that if you click
here.
2. Send to Multiple Recipients
Mail can be sent to additional recipients either as carbon copies (cc) or blind carbon copies (bcc).
This is done in a similar way, by placing '?cc=someoneelse@theirsite.com' after the initial address.
So the link looks like this:
<a href="mailto:someone@yoursite.com?cc=someoneelse@theirsite.com">Email Us</a>
cc can simply be replaced by bcc if you wish to send blind carbon copies.
This can be very useful if you have links on pages with different subjects. You might have the email on each page go to the appropriate person in a company but with a copy of all mails sent to a central address also.
You can of course specify more than one additional recipient, just
separate your list of recipients with a comma.
<a href="mailto:someone@yoursite.com?cc=someoneelse@theirsite.com, another@thatsite.com,
me@mysite.com">Email Us</a>
3. Combining Code
You can combine the various bits of code above by the addition of an '&' between each.
Thus adding
me@mysite.com?subject=Hello&cc=you@yoursite.com&bcc=her@hersite.com
would send an email with the subject 'Hello' to me, you and her.
4. Write the Email
You can also prefill the body of the email with the start of a message, or write the whole message if you like! To add some thing to the body of the email it is again as simple as above - '?body=' after the email address. However formatting that email can be a little tricky. To create spaces between words you will have to use
hex code - for example '%20' between each word, and to create new lines will mean adding '%0D'.
Similarly symbols such as $ signs will need to be
written in hex code.
If you also wish to add a subject line and send copies to multiple recipients, this can make for a very long and
difficult to write bit of code.
Try this link for example.
It will send a message to three people, with the
subject and the message filled in, all you need to do
is add your name.
(You don't actually need to send it by the way, the answer is - ME!)
But just look at the code!