Gmail Syntax Highlighter

Paste your code to an online (maybe offline) syntax highlighter, like http://tohtml.com/ . Then copy/paste it to gmail & send.


consider using gist.github.com

some benefits:

  • you can copy and paste the syntax highlighted code into gmail
    • (its not always perfect but gets the job done, see screenshot below) enter image description here
  • snippet(s) can be shared with a hyperlink (also bookmarkable)
  • you don't need an account to share code snippets
    • code can still be kept private and is only shared with those have the secret link
  • you can specify the language or snippet type, or even multiple snippets on a single page
    • each lang can be specified with github flavored markdown
  • you can also access historical changes of the snippet making it easy to track revisions over time

Unless you absolutely have to have the code in the email, I would just put your code on Pastebin and link to the code.

If you must put your code in the email, you could use a GreaseMonkey script such as this C++ highlighter, however that will not work for the person you're sending it to, only you. Another solution is to export your code as HTML (with coloring), and send it to the person as HTML. Try Visual Studio's CopySourceAsHtml plugin if you're using Visual Studio.