Creating Advanced XHTML Email Links: Include Subject, CC, BCC, and Email Body

By  on  

Creating email links is a piece of cake, right? It's as simple as:

<a href="mailto:live@wembley.com">Email Oasis</a>

Everyone knows this. Did you know, however, that you can include subject, CC, BCC, and email body text information in the link as well? Using a querystring-like syntax, you can do more with that simple link.

<a href="mailto:live@wembley.com">Email Oasis</a>

<!-- add the subject -->
<a href="mailto:live@wembley.com?Subject=Your Next Show">Email Oasis</a>

<!-- add the cc's and bcc's -->
<a href="mailto:live@wembley.com?Subject=Your Next Show&CC=johnl@beatles.com&BCC=paulm@wings.com">Email Oasis</a>

<!-- add some default body text -->
<a href="mailto:live@wembley.com?Subject=Your Next Show&CC=johnl@beatles.com&BCC=paulm@wings.com&Body=I can't wait for the next show!">Email Oasis</a>

Remember that simply placing email addresses on a page without encoding them first is like simply emailing spammers your email address. Encode your email addresses!

Recent Features

  • By
    9 Mind-Blowing Canvas Demos

    The <canvas> element has been a revelation for the visual experts among our ranks.  Canvas provides the means for incredible and efficient animations with the added bonus of no Flash; these developers can flash their awesome JavaScript skills instead.  Here are nine unbelievable canvas demos that...

  • By
    An Interview with Eric Meyer

    Your early CSS books were instrumental in pushing my love for front end technologies. What was it about CSS that you fell in love with and drove you to write about it? At first blush, it was the simplicity of it as compared to the table-and-spacer...

Incredible Demos

  • By
    GitHub-Style Sliding Links

    GitHub seems to change a lot but not really change at all, if that makes any sense; the updates come often but are always fairly small. I spotted one of the most recent updates on the pull request page. Links to long branch...

  • By
    Duplicate the jQuery Homepage Tooltips Using Dojo

    The jQuery homepage has a pretty suave tooltip-like effect as seen below: Here's how to accomplish this same effect using Dojo. The XHTML The above HTML was taken directly from the jQuery homepage -- no changes. The CSS The above CSS has been slightly modified to match the CSS rules already...

Discussion

  1. Your post here saved me some time at work, so thanks. I can just never remember if its PHP or URL encoding that is choosy about how CC is written (cc, CC, or Cc).

  2. garrobo

    George,

    I need help on getting a comment system like the one I’m writing on, my question to you is how to get it to my website is there a code that I need to download or do I need to purchase it let me know
    I’m in love with it. thanks

  3. I’d like to thank you, for this tutorial, as a newbie in xhtml, its a lot of thing i never know before, thanks for this ‘mailing’ tutorial. Im sorry for this bad english

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!