The magic behind the formatting on StackExchange is a great perl script called Markdown. Download it, and double-click the resulting Markdown_1.0.1.zip file.
Then, in terminal, type
chmod a+x ~/Downloads/Markdown_1.0.1/Markdown.pl
sudo cp ~/Downloads/Markdown_1.0.1/Markdown.pl /usr/local/bin/
Once you have that done, you can create a Service in Automator.
The service you create receives rich text in any application.
Uncheck the box that says Output replaces selected text.
Your service will contain two actions:
The first action is Run Shell Script.
Here is the shell script:
/usr/local/bin/Markdown.pl | /usr/bin/textutil -stdin -stdout -format html -convert rtf | /usr/bin/pbcopy
Your section action is Run AppleScript.
Here is the AppleScript:
tell application "System Events"
keystroke "v" using {command down}
end tell
Save the service, and, if you wish, assign it a keyboard shortcut using System Preferences » Keyboard » Keyboard Shortcuts » Services
Then, you can type text using the formatting codes you use on this site, and run this service to generate formatted text. This will only work if your mail messages are set up as Rich Text -- if you have plain text mail messages, running this service will simply erase the contents of your message, as your rich text formatted by the service will not be able to be pasted.
Best Answer
Though I was really looking for a way to copy from say TextMate into an email and preserve highlighting...
Since there are no answers, I found this answer as a decent workaround somewhere so I thought I'd share:
Head to an online syntax highlighting tool like tohtml.com and then copy and paste the text into your email
Fairly quick and easy to use :)