Defining a Default Subject in Mailto Links
With the mailto: HTML tag you can provide visitors to your site with a way to contact you. Find out how to define a default Subject: line that will automatically appear when somebody clicks the link.
Feedback via Email
You have a Web site, no? Be it personal, be it a fan site, be it a commercial one, you do want your visitors to have a way to contact you, right?
Fortunately, there's the mailto: HTML tag that makes it easy to for Web site visitors to send you an email by just clicking on a link.
Let's suppose that we do get quite a bit of email. Some of it seems to be related to our Web site, somebody apparently sent it using that witty mailto: link.
Unfortunately, these messages often come without any subject line -- it was just sent to a Web site, anyway --, or they have obscure subjects -- "Link", "photo" or, so that you cannot resist, "Can you help?". Maybe we can do something about this confusing situation?
Suggesting a Subject
Thankfully, those who created the mailto: tag also thought about a way to specify a default subject for the message created. It's not difficult to do at all.
Do you still remember the example from part one? If you have deleted the file you created back then... I'm afraid you have to type again (don't fret, exercise is always good :) (of course you could also pick quod_licet.html.txt from here, but only losers and very brilliant people do that).
Let us suppose we simply want to know that a message was sent via the mailto: tag, we strive to know that it somehow relates to our Web site. All we need is a default subject line of "Web Site Extraordinaire".
In line 9 of our example, it said:
<p>...non licet <a href="mailto:email@example.com"> firstname.lastname@example.org
Up to this point, everything stays the same. But now we insert some code that will make our subject wish come true:
?subject=Web Site Extraordinaire
The question mark indicates that what follows is one or more arguments to the "target" of the link. In this case the target is the email address we want the email to go. The argument is the suggested subject of the message.
Since there can be more than one argument (more about that later), we first need to specify what we want to specify. This is done by "subject". Following a sign of equality comes the text of our subject: "=Web Site Extraordinaire.
That's all there is to it, you can type just about anything as the subject. Have a try, play a bit with that feature while I try to sum up what we have learned today...
To specify a default subject line for a mailto: link, the email address is followed by "?subject=" and then the text of your subject. Everything else stays the same and in place.