I do a full-time job where I build tools required for one of the internal teams. I had to report my overseas manager about the solutions for a problem statement that he sends me before every week. There might involve a code snippet while sharing emails. In Microsoft Outlook, there is no way to embed a code snippet although it supports HTML-formatted emails. Styling the code snippet to send via Email not only makes the readers comfortable but also reflects your standards on how well you present your own code. Email may not be the best way to send code, but its worth embedding for a discussion over email.
How To Send Code Snippet in Microsoft Outlook Email
There are three ways to send code snippet in Microsoft Outlook. I personally do use Microsoft Office Outlook 2016 but the ways listed below do not depend on the Outlook version. Every Outlook does support custom styles.
Add Custom Style
The first way to think as a frequent user of Microsoft Outlook is to add custom styles and save them as a template. You may need it frequently. Choose "Courier New" as a font for the new style and thus it looks exactly as a code that it should look as. Now you can send your code snippet to your recipient and your email looks so well where the content and the code is differentiated clearly.
Via Notepad++
If you have Notepad++ on your Windows machine, the steps are simple and your code appears neat based on the language your code is. By default Notepad++ have a built-in plugin called "NppExport" which has the ability to export your code to Rich Text Format, PDF or even copy it in a clipboard so you can paste it in your Microsoft Outlook or any other applications to send code snippet.
- Open Notepad++
- Write your code, or open it.
- Go to Language and choose the type of code you wrote so that it applies colours and styles to keywords and variable of your code.
- Now go to Plugins > NppExport > Copy all formats to clipboard.
- Now open the Email that you are writing on Microsoft Outlook.
- Paste the code and send it.
TIP: Use a table with a cell and paste your code, so the code looks like it is in a box. This might increase the legibility and presentation. However, it all of your choice.
Insert Object
Another way to embed a code object to the email is to insert an object. Go to Insert tab on Outlook. Click on "Create New Object". Select OpenDocument Text as an object type. A box will appear on the email editor. Just paste your code to the box and it's done. There is no direct way to insert a code snippet directly into email but we can make use of the above 3 ways to send code snippet in Microsoft Office Outlook. What is the way you follow to send code snippet to your colleague or friend or fellow programmer? Which method do you think is the best and effective way? Let us know in the comments below.