The mailto syntax is pretty simple, but sometimes you might run into problems with some mail clients (AKA Outlook Web Access). Most of them are very forgiving and you can drop a comma for example right into the body of the mailto and have no problems, but it’s better not to do that. It’s much safer if you use hexadecimal numeric values for your special characters. For example a comma is %2c and a space is %20.
Why do I care? It works in the email clients I tested!
That’s fine and dandy, but your audience may be using a client you haven’t tested, one like say Outlook for web. I dealt with an issue like this recently where Outlook was truncating the body copy after the first comma appeared. It was a mailto confirming attendance to an event, so losing the copy was not very helpful for for the end user or the organizer trying to get responses. Now granted a web form would have been a better option, but time restraints resulted in using a simple mailto.
Lets quickly go over some of the mailto syntax.
mailto:email@example.com?body=I will be attending the party, it should be a blast
Subject and Body
mailto:firstname.lastname@example.org?Hello&body=I will be attending the party, it should be a blast.
There are also CC and BCC values that you can drop into your mailto string.
These examples will work fine in most email clients, but not all. First if you want valid XHTML syntax your ampersands should be &. This should not affect your mailto functionality either way, but having valid markup is always a good thing. Second you should use hexadecimal values for your spaces and commas. Here’s an example of a safer mailto.
Subject and Body
The only difference with this example is %20 for spaces and %2c for commas and 2E for a period. This example is much more bullet proof than the first example although you probably don’t need it for the period, but then again I thought the comma would be safe.
Another character you may need is a line break. %0A will give you a line break. Using two will give you a paragraph space.
mailto:email@example.com?Hello&body=I%20will%20be%20attending%20the%20party%2c%20it%20should%20be%20a%20blast%2E%0A%0AI will be bringing a guest too%21%2E
If you are ever unsure of a character just drop it’s hex value in place of it. Most of the characters should work fine, but some like the comma will not. Others like spacing must be added if breaks are needed. You can easily find hexadecimal code lists all over the web, just remember to add the percent (%) symbol in front of the hex.