How to use Outlook to send snippets of code?

As a programmer in a large corporation, I often send Outlook emails containing sample code.

I actually type the code directly in the email. This inevitably causes problems, because Outlook really likes to format text in a pleasant, but useless way. My code must be copied from email and directly to the code, so I do not want Outlook to enter it by adding special characters or anything else.

Therefore, I always need to configure parameters such as:

  • Do not use the first letter of each sentence (otherwise all my functions will be P public instead of p public)
  • Disable smart quotes (fancy quotes do not copy + paste from emails is good)
  • Never use spell checking (because it is just annoying).

I also like that my code is in a monospaced font, black, indented and smaller than in other text. I tried to create a style for this, but for some reason the style never saves. :-( [edit: it turns out, I did not tell him to work on "new documents based on this template"]

Is there a way to put code in <pre> blocks or something that tells Outlook to ignore all of these rules and format the code the way I want? If not, what methods did you find to send snippets of code in your Outlook mail messages without getting too annoying?

+81
outlook outlook-2007
Jul 19 '09 at 23:22
source share
7 answers

If you use Outlook 2010, you can define your own style and select the formatting you need, there is one option for the language in the format options, here you can specify the language and indicate whether you want the spellcheck to ignore text with this style.

With this style, you can insert code in the form of text and choose your new style. Outlook will not correct the text and will not spell check on it.

The following is a brief description of the style that I defined for emailing snippets of code.

Do not check spelling or grammar, Border: Box: (Single solid line, Orange, 0.5 pt Line width) Pattern: Clear (Custom Color(RGB(253,253,217))), Style: Linked, Automatically update, Quick Style Based on: HTML Preformatted 
+26
May 15 '13 at 11:11
source share

In a few years I have an answer.

  • Use an online code shortcut like http://tohtml.com/ to highlight your code so you can paste the highlighted code from your IDE into Word. Depending on your IDE, you can skip this step.

  • In Word 2010, go to insert-> object-> openDocument Text. Steps 2-3 are documented in How can you display code snippets in MS Word save format and syntax highlighting? .

  • Paste the selected code into the object.

  • Copy the entire object.

  • Right-click-> paste in a special object in Outlook.

This gives you a dedicated code code for use in emails in Outlook 2010.

+55
Sep 08
source share

If notepad ++ is installed on your computer, you can copy the test in RTF format (formatted text format) and paste it into your mail.

1) Paste the code snippet into Notepad ++;

2) In the menu bar, go to "Plugins → NppExport → Copy RTF to clipboard"

3) Paste into your email address

4) Done

+22
Jul 28 '16 at 7:24
source share

Here, what works for me is the fastest and causes the least amount of pain / annoyance:

1) Paste the code snippet into sublime ; make sure your syntax looks good.

2) Right-click and select "Copy as RTF"

3) Paste into your email address

4) Done

+7
Jul 06 '15 at 19:34
source share

If you attach your code as a text file and your recipient (s) has the option "show attachments embedded" (I believe that it is installed by default), Outlook should not distort your code, but it will be copied / directly from electronic mail.

+6
Jul 19 '09 at 23:27
source share

If you do not want to attach the code in the file (it was good advice, ChssPly76, I need to check it), you can try changing the default message format messages to rich text (Tools - Options - Mail Format - Message Format) instead of HTML. I found out that the HTML format is for formatting HTML code (btw, Outlook uses MS Word HTML rendering engine, which sucks a lot of time), but rich text works fine. Therefore, if I copy the code from Visual Studio and paste it into an Outlook message, when using rich text it looks pretty good, but in HTML mode it is a disaster. To disable smart quotes, auto-correction, and other artifacts, configure the corresponding parameter using Tools - Options - Spelling - Spelling and AutoCorrection; You can also play with copy-paste settings (Tools - Options - Mail Format - Editor Options - Cut, Copy and Paste).

0
Jul 19 '09 at 23:51
source share

Will sending mail be in plain text?

"How to send a regular text message in Outlook" :

  • Choose action | New mail using | Plain text from a menu in Outlook.
  • Create your message as usual.
  • Click "Submit" to send it.

Being plain text, it should not spoil your code, smart quotes, auto-capital letters, etc.

Another possible option, if this is a common problem within the company, maybe you can set up an internal site to insert the code, there are many open sources, for example Open Pastebin

0
Jul 20 '09 at 1:04
source share



All Articles