How to send programming code snippets in Outlook

I sometimes include a programming code snippet in an Outlook email and it's a very distracting and frustrating experience, because Outlook has an assumption that everything in an email message is natural language (e.g. English). So it tries to flag "spelling errors", attach links and other such non-helpfulness. How can I get Outlook to not do that please? Is there some kind of "leave this text alone" (or "leave this message alone") option, kind of like the <pre> tag in HTML?


Solution 1:

I've had similar frustration when sending configuration output from a router or switch in an email, and I fixed it by creating a new style, and "stealing" the HTML of code snippits on Stack Exchange.

For example:

{master:0}
user@switch> show configuration chassis 
alarm {
    management-ethernet {
        link-down ignore;
    }
}
  1. Steal a Sample and Create a New Style

    I liked how the above looked so much that I simply copied the text above, and pasted it in a new email in outlook. Then, select it, click styles, then "Create a New Style":

    Create a Style Prompt

  2. Name it, and Modify it

    Then I gave it a name and clicked "Modify" to look at the more advanced options:

    Create New Style from Formatting

    You want to disable Spell Check, for example. Go to "Format" then "Language" then check "Do not check spelling or grammar":

  3. Save It

    Anyway, from there you opt check the option for "New documents based on this template". Click "OK".

IMPORTANT

This will NOT SAVE for future emails unless you save it as a "Style Set"

Go to "Format Text" on the ribbon, then within "Styles", click "Change Styles" > "Style Set" > "Save as a New Style Set". After naming and saving it, you'll have a style set you can return to. If you want this as your default style set (you probably do), click the "Change Styles" button again, and click "Set as Default".

Solution 2:

You don't say which version of Outlook you're using, but if you're on 2007 or 2010, the "Adding a 'Paste Code' feature to Outlook 2010/2007" blog entry might be useful to you.

In summary:

  1. Enable macros
  2. Enable "Developer Mode"
  3. Add a form using "Form Manager"
  4. Add the VBA code (macro)
  5. Create buttons to allow you to "Paste Code"

All the needed steps are outlined in the blog entry, including VBA code.