This content on this blog is old and out of date. Please visit my new blog at http://martineau.tv to keep up-to-date with the latest news.

Rather Splendid

The personal weblog of Zander Martineau

MailTo Syntax

I have recently been designing some html emails for Arc & Co and they needed an email link within the body of their email. This link needed to include a subject, CC, BCC and body text and I did not know the syntax for all of it, so Google to the rescue where I stumbled upon a simple article on the University of Nebraska-Lincolns’s website which I am reproducing and adding to here for reference.

As the code used for html emails is still quite basic, so that all possible email programs can read them well, and I did not want to risk using a javascript based obfuscator I had to use the mailto syntax when usually I would use a great mac app called Enkoder (you can also use their online form).

The MailTo command can do more than enter a single e-mail address in the “Send To” field while activating your e-mail program.

Feature Syntax
Address message to multiple recipients , (comma separating e-mail addresses)
Add entry in the “Subject” field subject=Subject Field Text
Add entry in the “Copy To” or “CC” field cc=id@internet.node
Add entry in the “Blind Copy To” or “BCC” field bcc=id@internet.node
Add entry in the “Body” field body=Your message here
Within the body use “%0A” for a new line,
use “%0A%0A” for a new line preceded by a blank line (paragraph),
see example below.

Notes

“ “ (beginning and ending double quotes) are necessary if any spaces are used

Mailto parameter should be preceded by “?” for the first or only parameter and “&” for second and subsequent parameter.

Some examples, with actual HTML Code included, follow:

Simple MailTo
<a href="mailto:mailto@rathersplendid.net">Simple MailTo</a>

MailTo with Multiple Recipients
<a href="mailto:mailto@rathersplendid.net,MAILTO@RATHERSPLENDID.NET">MailTo with Multiple Recipients</a>

MailTo with Subject
<a href="mailto:mailto@rathersplendid.net?subject=Comments from MailTo Syntax Page">MailTo with Subject</a>

MailTo with a Copy
<a href="mailto:mailto@rathersplendid.net?cc=MAILTO@RATHERSPLENDID.NET">MailTo with a Copy</a>

MailTo with a Blind Copy
<a href="mailto:mailto@rathersplendid.net?bcc=MAILTO@RATHERSPLENDID.NET">MailTo with a Blind Copy</a>

MailTo with message already started in Body...
<a href="mailto:mailto@rathersplendid.net?body=I am having trouble finding information on ">I am having trouble finding information on</a>

MailTo with multiline message in Body.
<a href="mailto:mailto@rathersplendid.net?body=The message's first paragraph.%0A%0aSecond paragraph.%0A%0AThird Paragraph.">

NOTE: Use “%0A” for a new line, use “%0A%0A” for a new line preceded by a blank line.
Features may be used in any combination

MailTo with Subject, a Recipient, a Copy and a Blind Copy
<a href="mailto:mailto@rathersplendid.net?subject=MailTo Comments&cc=MAILTO@RATHERSPLENDID.NET&bcc=MAILTO@ratherRSPLENDID.NET">

All of the above – MailTo with Subject, CC, BCC and a few Body lines.
<a href="mailto:mailto@rathersplendid.net?subject=MailTo Comments&cc=MAILTO@RATHERSPLENDID.NET&bcc=MAILTO@RATHERSPLENDID.NET&body=The message's first paragraph.%0A%0aSecond paragraph.%0A%0AThird Paragraph.">

Remember to use only one ? (question mark), when providing multiple entries beyond e-mail address.

Something else to remember is that you should not use any ampersands (&) in you subject or body copy as it will break the code and your code will render incomplete. Something I learnt the hard way.

comments powered by Disqus