views:

357

answers:

3

As a programmer at a big corporation, I frequently send Outlook emails that contain code samples.

I'll actually type code directly into an email. This inevitably causes problems, as Outlook really likes to format text in pleasing but crazy ways. My code needs to be copyable out of the email and directly into code, so I don't want Outlook to mess with it by adding special characters or whatnot.

So I always need to tweak options like:

  • Don't capitalize first letter of every sentence (else all my functions be Public instead of public)
  • Disable smart quotes (fancy quotes don't copy+paste out of emails well)
  • Never use spell checker (because it just gets annoying)

I also like my code to be in a monospaced font, black, indented, and smaller than other text. I've tried to make a Style for this, but for some reason the Style never saves. :-(

Is there some way to put code in <pre> blocks or something that tells Outlook to ignore all these rules and format code the way I want it to? If not, what ways have you found to send code snippets in Outlook emails without it getting super annoying?

+4  A: 

If you attach your code as a text file and your recipient(s) have "show attachments inline" option set (I believe it's set by default), Outlook should not mangle your code but it will be copy/paste-able directly from email.

ChssPly76
This works, but is not really the workflow I want. I would rather not have to create a file somewhere to attach a small code snippet. Rather, I want to just type directly into the email - perhaps by surrounding some <code> markup or something like I'd do on a wiki. However, from the answers everybody came up with, it appears as if nobody knows of a better way to do this in Outlook at the moment.
Mag Roader
A: 

If you do not want to attach code in a file (this was a good tip, ChssPly76, I need to check it out), you can try changing the default message format messages to rich text (Tools - Options - Mail Format - Message format) instead of HTML. I learned that Outlook's HTML formatting screws code layout (btw, Outlook uses MS Word's HTML rendering engine which sucks big time), but rich text works fine. So if I copy code from Visual Studio and paste it in Outlook message, when using rich text, it looks pretty good, but when in HTML mode, it's a disaster. To disable smart quotes, auto-correction, and other artifacts, set up the appropriate option via Tools - Options - Spelling - Spelling and AutoCorrection; you may also want to play with copy-paste settings (Tools - Options - Mail Format - Editor Options - Cut, copy, and paste).

Alek Davis
This works too, but I still need to go change the font to Courier New and indent it and change it to black and whatnot.
Mag Roader
Hmmm... I do not have to do this. The only problem I noticed was the tabs, so if your Outlook settings for tabs is different from VS, than tab-based alignments may be a bit off, but that's about it.
Alek Davis
A: 

Would sending the mail as plain-text sort this?

"How to Send a Plain Text Message in Outlook":

  • Select Actions | New Mail Message Using | Plain Text from the menu in Outlook.
  • Create your message as usual.
  • Click Send to deliver it.

Being plain text it shouldn't screw up your code, with "smart" quotes, auto-capitalisation and such.

Another possible option, if this is a common problem within the company perhaps you could setup an internal code-paste site, there's plenty of open-source ones around, like Open Pastebin

dbr
This'll certainly work if I want the entire email to be in plain text, but more what I am looking for is just small portions of it to be code samples. The rest might have nice headings, bullet points, tables, etc....I write really LONG emails sometimes :-)
Mag Roader