How to Format Code in an Outlook Email

Example of formatted code in an Outlook email

TL;DR

  1. Go to https://tohtml.com/
  2. Paste your code
  3. Select your type (language)
  4. Select your style
  5. Click Highlight
  6. Copy/paste

The Challenge

Microsoft is always trying to “help” us by automatically formatting our text, creating lists whether or not we want them, and slowing down our machines until we apply system updates.

The same applies to Outlook. I don’t know about you, but when I see a code snippet, I like to see it formatted accordingly, not just blending in with everything else. Unfortunately, that’s somewhat difficult with Microsoft Outlook.

The Fix

A genius Stack Overflow user pointed the community in the direction of a tool originally created by Oleg Parashchenko called ToHTML. Here’s how to use it:

1. Navigate to ToHTML.com.

2. Paste your code snippet into the “Source code” input field:

Pasting code into ToHTML.com

3. Click the Highlight button.

4. Select your Type (language). In this example, I’m using SQL:

Formatting a code snippet as SQL with ToHTML

5. Select your style. For Outlook emails, I prefer navy:

Formatting the code style as Navy with ToHTML

6. Click Highlight again to apply your changes:

Applying all changes to ToHTML code snippet

7. Your formatted code can be previewed in the Preview section. Click Copy to clipboard:

Preview of highlighted code for Outlook at ToHTML

8. Paste your code snippet into a new Outlook email. Yes, Outlook will highlight what it perceives as spelling errors. Turn a blind eye:

Pasting formatted results from ToHTML into Outlook email

9. Send your email. Here’s how it looks to the recipient:

Example of formatted code in an Outlook email

10. Rejoice that the battle has been won.

0 0 vote
Article Rating
Share on facebook
Facebook
Share on google
Google+
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest
Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Stephen Morton
Stephen Morton
24 days ago

Unless your code is company-confidential in which case you probably do not want to paste it into a random internet website.

As an alternative, you could edit it in VSCode and then paste it into Outlook Web.

2
0
Would love your thoughts, please comment.x
()
x