Stop Pasting Code as Plain Text — Try This Instead
By David Park
Yes, you can format code in Outlook email. But Outlook strips most formatting on paste — including tabs, line breaks, and monospace fonts — unless you know which method matches your use case.
The Short Version
Method
Pros
Cons
Best For
Paste as plain text + manual font change
Works offline. No setup. Uses built-in Ctrl+Space reset.
No automatic indentation. Tabs collapse in some clients (e.g., Outlook Web App).
Quick internal notes to colleagues using desktop Outlook.
Paste from Notepad++ or VS Code with 'Paste Special'
Preserves line breaks and spacing. Works in Outlook 365 & 2019.
Requires external editor. Doesn’t retain color or syntax highlighting.
Sharing config snippets or SQL queries with developers.
Use HTML tables (manual or via online converter)
Most consistent across Outlook desktop, OWA, and mobile. Supports line numbers.
Time-consuming. Breaks if recipient uses strict HTML filters (e.g., some shared mailboxes).
Client-facing documentation or security-sensitive code reviews.
Screenshot + alt text
Guaranteed fidelity. No formatting loss. Accessible if alt text is written well.
Not editable. Fails for long scripts. Screen readers read alt text, not code logic.
One-off troubleshooting examples sent to non-technical stakeholders.
Method 1: Paste as plain text + manual font change
This is the fastest fallback — and it works even when you’re offline or using Outlook 2016 on a locked-down corporate laptop.
First, copy your code block from any editor (VS Code, Sublime, even Notepad). Don’t paste yet.
In Outlook desktop, click inside the message body. Press Ctrl+Space. This clears any existing font or paragraph formatting — critical step most people skip.
Now paste (Ctrl+V). Right-click the pasted text → Font… → choose Courier New or Consolas (if installed) → set size to 10 or 11 pt.
Go to Home tab → click the small arrow in the bottom-right of the Paragraph group → check Don’t add space between paragraphs of the same style. Click OK.
Why this matters: Outlook auto-adds extra line spacing after each paragraph. That turns clean Python indents into unreadable vertical gaps. Turning this off keeps your def blocks tight.
This method fails in Outlook Web App (OWA) — it ignores font changes on paste and collapses consecutive spaces. So don’t rely on it for external clients using OWA.
Method 2: Paste from Notepad++ or VS Code with 'Paste Special'
This solves the tab-and-space collapse problem that ruins shell scripts and YAML.
Open your code in Notepad++. Go to Encoding → Character sets → UTF-8 (not UTF-8-BOM). Save.
In Outlook desktop, click where you want the code. Press Ctrl+Alt+V. Choose Unformatted Unicode Text. Click OK.
That shortcut bypasses Outlook’s auto-formatting engine entirely. You’ll get literal line breaks and preserved indentation — even with mixed tabs and spaces.
Test it: paste this into Notepad++ first:
if [ -f /etc/os-release ]; then
. /etc/os-release
echo "OS: $NAME"
fi
Then use Ctrl+Alt+V in Outlook. It stays intact.
Note: This only works in Outlook desktop (365, 2021, 2019). It’s ignored in Outlook Web App and Outlook for Mac. Also fails in shared mailboxes if the delegate uses OWA — they’ll see collapsed whitespace.
Method 3: Use HTML tables (manual or via online converter)
This is the only method that survives forwarding, OWA rendering, and Outlook mobile apps — if you do it right.
You *don’t* need to write raw HTML. Use a free tool like Senseful Solutions’ Code Formatter. Paste your code, pick language, select ‘Outlook-safe HTML’, copy output.
Back in Outlook desktop: go to File > Options > Mail > Compose messages → ensure HTML is selected under ‘Compose messages in this format’.
Then press Alt+H, V, H to open ‘Paste Special’ → choose HTML Format. Paste.
The result is a table with <pre>-like behavior — monospace font, fixed width, preserved line breaks.
Here’s what it looks like when rendered correctly:
Line
Code
1
SELECT id, name FROM users
2
WHERE status = 'active'
3
ORDER BY created_at DESC;
4
-- Returns last 10 active users
Counterintuitive tip: Never use ‘Insert → Table’ manually in Outlook. Its auto-resizing breaks fixed-width code. Always paste pre-built HTML tables.
This method also works in shared mailboxes — as long as the sender uses desktop Outlook and the HTML paste option. Delegates using OWA will still see clean rendering.
Which Should You Choose?
Ask yourself three questions:
Is the recipient using Outlook desktop (not OWA or mobile)? → Use Method 2 (Ctrl+Alt+V).
Are you sending externally or to someone who forwards often? → Use Method 3 (HTML table).
Is this a quick internal Slack-style note? → Use Method 1, but always hit Ctrl+Space first.
Here’s a decision table based on real scenarios:
Your Situation
What Happens If You Just Paste
Fix With
Sending Terraform config to DevOps team (all on Outlook 365 desktop)
Tabs turn to single spaces. Indentation lost. JSON keys misaligned.
Method 2: Paste from VS Code using Ctrl+Alt+V → Unformatted Unicode Text
Emailing API spec to client using Outlook Web App
All line breaks disappear. Code runs together in one paragraph.
Method 3: Paste pre-formatted HTML table
Quick reply to teammate about a bash one-liner in ‘Projects/2024/Q3’ folder
Extra blank lines added between commands. Hard to read.
Sharing PowerShell script with IT helpdesk (mix of desktop + OWA users)
Desktop users see partial formatting. OWA users see garbled spacing.
Method 3: HTML table — renders consistently for all
Pasting into a shared mailbox draft (you’re a delegate)
Formatting lost if primary owner opens in OWA later.
Method 3 — safest for cross-client reliability
David Park
David brings deep expertise in office supply evaluation and procurement. He has tested hundreds of products to help teams make informed purchasing decisions.