VBA Paste Plain Text To Outlook Email Body

Abstract: Strip rich formatting from clipboard content when pasting into Outlook email bodies using VBA Word Editor automation.

Created: 2026-09-15 by

To paste plain text into an Outlook email body using VBA, you must use the Word Editor object model and explicitly set the Format property of the Selection to wdFormatPlainText. This approach ensures that any clipboard content is stripped of rich formatting before insertion, preventing layout issues in your final message.

Understanding the Outlook Object Model

When automating Microsoft Outlook with VBA, it is crucial to understand that the email body is not a simple text box. Since Outlook 2007, the email editor has been powered by Microsoft Word. This means that when you create or modify an email item, you are actually interacting with a hidden instance of the Word application. To manipulate the body content programmatically, you cannot simply assign a string to the Body or HTMLBody property if you want to preserve complex clipboard operations or specific formatting states. Instead, you need to access the underlying Word document associated with the mail item.

This architectural detail explains why standard copy-paste methods often fail or carry over unwanted styles from Excel. By targeting the Word Editor directly, we gain full control over the selection range. We can simulate user actions like pressing Ctrl+V but enforce a strict plain text output. This method is robust because it relies on the native capabilities of the Word automation engine rather than trying to parse HTML strings manually.

Setting Up References for Early Binding

For the most reliable development experience, especially during the coding phase, it is recommended to use early binding. This allows the Visual Basic Editor to provide IntelliSense and autocomplete features, which significantly speeds up debugging. To enable this, open your VBA editor by pressing Alt + F11. Navigate to the Tools menu and select References.

In the references dialog box, scroll down and check the following libraries:

  • Microsoft Outlook xx.x Object Library: Provides access to Outlook-specific objects like Application, MailItem, and Inspector.
  • Microsoft Word xx.x Object Library: Essential for accessing the Word Editor, Selection object, and constants like wdFormatPlainText.

Replace xx.x with the version number installed on your machine (e.g., 16.0). Using these references ensures that the compiler knows exactly what properties and methods are available, reducing runtime errors caused by typos or missing definitions. If you prefer late binding to avoid reference dependencies on different machines, you would need to declare all objects as generic Object types and define constant values manually, but early binding is preferred for clarity and error checking during development.

Implementing the Plain Text Paste Function

The core logic involves creating a new mail item, activating its inspector window to expose the Word editor, and then executing a paste operation with a specific format flag. The following code demonstrates this process step-by-step. It assumes you have already copied some data to the Windows clipboard, either from Excel or another application.

Sub SendPlainEmail()
    Dim olApp As Outlook.Application
    Dim olMail As Outlook.MailItem
    Dim wdDoc As Word.Document
    Dim wdSel As Word.Selection
    
    ' Create Outlook Application Instance
    Set olApp = New Outlook.Application
    Set olMail = olApp.CreateItem(olMailItem)
    
    ' Activate the Inspector to get the Word Document Object
    olMail.Display
    Set wdDoc = olMail.GetInspector.WordEditor
    Set wdSel = wdDoc.Windows(1).Selection
    
    ' Clear existing content if necessary
    wdSel.WholeStory
    wdSel.Delete
    
    ' Paste as Plain Text
    wdSel.PasteSpecial Link:=False, _
                       DataType:=wdPasteText, _
                       Placement:=wdInLine, _
                       DisplayAsIcon:=False
                       
    ' Optional: Set subject and recipients
    olMail.Subject = "Report Data"
    olMail.To = "[email protected]"
    
    ' Show the email for review before sending
    olMail.Display
End Sub

In this script, olMail.Display is critical. Without displaying the item first, the GetInspector method may return nothing or cause an error because the Word editor is not yet instantiated. Once the inspector is active, GetInspector.WordEditor returns the actual Word document object. We then define a selection range within that document. The PasteSpecial method is where the magic happens. By setting DataType:=wdPasteText, we force Word to interpret the clipboard data as unformatted text, ignoring fonts, colors, and table structures from the source.

Handling Errors and Cleanup

While the basic script works, production-ready code should include error handling. Outlook interactions can fail if the user cancels the display window or if security prompts appear. You should wrap the execution in an On Error GoTo block to ensure that objects are properly released. Always set your object variables to Nothing at the end of the subroutine to free up memory. This practice prevents lingering Outlook processes in the background, which can slow down your system.

Additionally, consider adding a check to see if Outlook is already running. Creating a new instance every time might spawn multiple Outlook windows if the user already has one open. Using GetObject for existing instances and CreateObject only when necessary is a more efficient strategy. However, for simple automation tasks, New Outlook.Application is usually sufficient and less prone to connectivity issues.

Alternative Approaches

If you do not need to interact with the clipboard and simply want to insert a string variable into the email body, you can skip the Word Editor entirely. You can assign a plain string directly to the Body property of the MailItem. This is faster and does not require the Word library reference. However, this method does not support pasting complex data structures or preserving line breaks from Excel ranges as effectively as the Word Editor approach. For simple text messages, direct assignment is cleaner.

Another alternative is using HTML bodies. You can construct an HTML string in VBA and assign it to the HTMLBody property. This gives you full control over styling but requires manual construction of tags. It is useful when you need precise formatting that plain text cannot provide, such as hyperlinks or colored text. Yet, for the specific requirement of stripping formatting from external data, the PasteSpecial method remains the most straightforward solution.

For users dealing with large datasets, consider optimizing the clipboard content before pasting. Ensure that the source data is formatted as plain text or CSV in Excel before copying. This reduces the chance of Word interpreting cell borders or fill colors as part of the document structure. Combining clean source data with the PasteSpecial technique yields the most predictable results.

Frequently Asked Questions

Why does my email still show bold text after using PasteSpecial?

The PasteSpecial method strips formatting from the clipboard source, but it does not remove existing formatting in the destination document. If the Word editor already contains styled text, pasting plain text will insert unformatted characters next to styled ones. To fix this, clear the entire selection or document body before pasting, as shown in the example code.

Can I send the email automatically without displaying it?

Yes, but you must be careful with the Word Editor. If you do not call Display, the inspector may not initialize immediately, causing GetInspector to fail. A safer approach for silent sending is to build the HTML body string in VBA and assign it to HTMLBody, then call Send directly. Avoid manipulating the Word Editor for silent sends unless you have handled the initialization sequence correctly.

How do I handle line breaks from Excel cells?

Excel uses Alt+Enter for line breaks within cells, which translates to vbCrLf in VBA. When you copy a range and paste it as plain text, Word typically preserves these line breaks. If they are lost, ensure the source range is copied correctly. You can also manually insert line breaks in your VBA string using Chr(10) if constructing the text programmatically.

What if I get a Compile Error: User-defined type not defined?

This error occurs when you use early binding but forget to add the required reference library. Check the Tools > References menu in the VBA editor and ensure that both the Outlook and Word Object Libraries are checked. If you cannot add references, switch to late binding by declaring variables as Object and defining constants like wdPasteText manually with their numeric values.

Is there a way to paste without using the clipboard?

No, the PasteSpecial method inherently relies on the Windows clipboard containing the data you wish to insert. If you want to avoid clipboard interference, you must construct the text string in VBA using concatenation or array joining, and then assign that string to the Body or HTMLBody property. This bypasses the need for clipboard operations entirely.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More