McAfee Software Downloads
ParetoLogic > Products > Spam Controls > Tutorials > Specifying Subject And Body In A Mailto Link

 

Specifying Subject And Body In A Mailto Link

Introduction To The Mailto Link

The mailto link is an HTML tag that, when clicked, opens the users email client in the new message composition window. The email address of the recipient is prefilled with the email address that follows the mailto: command. For instance <a href=”mailto:name@domain.com”>email</a> would provide a link that would open a new email message to name@domain.com. It is also possible to prefill and amend certain other email attributes using other variables within the link code.

What Can Be Done With Mailto

While the mailto link is considered to be an attraction for spam emails it does also provide a method for genuine customers to contact you. In these cases, and especially if you have several mailto links throughout a website, you can specify subject and body contents for the emails that are created. By using these effectively you can effectively track emails as they arrive and before you've read them. You can even have the emails sent to a list of recipients.

Emailing Multiple Recipients

There are several ways to send an email to multiple recipients. As well as including a list of email addresses within the To field you may choose to use the CC (Carbon Copy) or BCC (Blind Carbon Copy) fields.

Sending To A List Of People In The To Field

To include multiple recipients as a single list of people within the To filed of a mailto link add a comma separated link without spaces. You can add as many names to this list as you like simple by adding another comma followed by the next name.

<a href=”mailto:name@domain.com,another.name@domain.com”>email</a>

Using CC and BCC Fields

To add recipients to the CC or BCC filed this means adding new headers to the email. In order to add new variables to your mailto link the original HTML needs to be followed by a ? and then the appropriate code. To add a cc field the code to be added, for example, would be “?cc=another.name@domain.com”. To include a recipient in the BCC field the code would be the same except you should replace the cc with bcc.

Using The & Symbol To Include More Than One Variable

When adding more than one variable we do not use the ? again. Instead we use an & symbol to indicate that there is another variable.

<a href=”mailto:name@domain.com?cc=another@domain.com&bcc=onemore@domain.com”>email</a>

Adding A Prefilled Subject Line

Adding a subject line can help manage and organize emails as soon as you receive them. Having uniformity in the messages you receive also makes for an ideal way to manage newsletter subscriptions and unsubscribe requests. The variable for the subject line is subject and would be added in the same way as the cc or bcc field as follows:

<a href=”mailto:name@domain.com?subject=inquiry”>email</a>

Creating The Email Content

Finally you may also want to add the subject body to the email. This can begin to make the code look a little messy and extremely long winded but may have its genuine uses for many of you. The variable to add content to the email is body like this:

<a href=”mailto:name@domain.com?body=thanks”>email</a>

Long Winded Code

Where the code can become messy is if, as is likely to be the case, you want to add multiple words to either the subject or the body. With an HTML link special characters (which includes a space) need to be added using their Hex code. For a space this code is %20 and for a line break or new line the code is %0D. This means to have an email link sent to one person, copied to another, and containing a fairly standard subject and body the HTML code would look like this:

<a href=”mailto:name@domain.com?cc=another@domain.com&subject=quote%20request&body=please%20provide%20prices%20for%20the%20following%20project%0D%0DProject%20description”>email</a>

Using Mailto Generators

Fortunately, to facilitate easier creation of email mailto links there are a number of mailto generators online. These are small and simple scripts that will create the necessary HTML code for you. All you need do is add the fields and contents that you require and click generate. These can be found by searching any of the major search engines for the term “mailto generator”.

Working With Mailto Links

Emails are a staple component of communication in modern life. If you run a website then chances are you have genuine reason to want your visitors to contact you. Including a mailto link on your site can cause an increase in the amount of spam you receive but it also provides you with a reliable but flexible method of customer contact. Using the appropriate code, or a mailto generator, you can insert links onto the pages of your site that, when clicked, will open a new mail message with the appropriate sections of the email already filled in.