• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Remove Attachments From Messages

Slipstick Systems

› Developer › Remove Attachments From Messages

Last reviewed on November 25, 2024     27 Comments

Applies to: Outlook (classic), Windows

This question from Outlook user wanted to know how to remove several attachments from a message in one step.

I want to keep sent messages but not the attachments. Is there an easier method than clicking on the attachment to delete it? Better yet, can I select several sent messages and remove the attachments from all of the messages?

Outlook doesn't have this functionality built in so you'll need to use an add-in or VBA, but yes, it can be done.

See Attachment Management Tools for Outlook for add-ins or More Information for additional macros, including code samples that can save the attachments to the hard drive before deleting them from the message.

This code will work with sent or received messages, in any folder. To use, add the code to the VBA editor, select the messages that you want to delete the attachment from and run it.

Sub DeleteAllAttachmentsFromSelectedMessages()
    Dim oAttachments       As Attachments
    Dim selItems            As Selection
    Dim oMsg              As Object
    Dim lngAttachmentCount  As Long
    
    ' Set reference to the Selection.
    Set selItems = ActiveExplorer.Selection
    
    '  Loop though each item in the selection.
    For Each oMsg In selItems
        Set oAttachments = oMsg.Attachments
        
        lngAttachmentCount = oAttachments.Count
        
    ' Loop through attachments until attachment count = 0.
        While lngAttachmentCount > 0
            oAttachments(1).Delete
            lngAttachmentCount = oAttachments.Count
        Wend
        
        oMsg.Save
    Next
    
    MsgBox "All Done. Attachments were removed.", vbOKOnly, "Message"
    
    Set oAttachments = Nothing
    Set selItems = Nothing
    Set oMsg = Nothing
End Sub

Remove Attachments From Forwards

A user needed to forward a message, but without the attachment and with the attachment name in the message body.

As written, this works with a selected message, not an open message.

You will need to set a Reference to the Microsoft Word Object Model in Tools, References.

Public Sub RemoveForward()
Dim oItem As MailItem
Dim oAtt As Attachment
Dim strAtt As String
Dim olInspector As Outlook.Inspector
Dim olDocument As Word.Document
Dim olSelection As Word.Selection

Set oItem = Application.ActiveExplorer.Selection.item(1)
strAtt = ""

For Each oAtt In oItem.Attachments
    strAtt = strAtt & "<<" & oAtt.FileName & ">> "
Next oAtt

   Dim oMsg As MailItem
   Set oMsg = oItem.Forward
   oMsg.To = "alias@address"
   oMsg.Display
    
    Set olInspector = Application.ActiveInspector()
    Set olDocument = olInspector.WordEditor
    Set olSelection = olDocument.Application.Selection

  olSelection.InsertBefore strAtt

For Each oAtt In oMsg.Attachments
    oAtt.Delete
Next oAtt
   
Set oItem = Nothing
End Sub

 

How to Use Macros

First: You will need macro security set to low during testing.

To check your macro security in Outlook 2010 and above, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security.

After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.

Open the VBA Editor by pressing Alt+F11 on your keyboard.

To put the code in a module:

  1. Right click on Project1 and choose Insert > Module
  2. Copy and paste the macro into the new module.
  3. Set a reference to the Word Object Model in the VBA editor's Tools, References dialog.
    Reference the Word object model in Outlook's VBA Editor
  4. Customize the ribbon or Quick Access Toolbar to add a button to the macro for easy access.

More information as well as screenshots are at How to use the VBA Editor

More Information

Housekeeping and Message Management Tools for Outlook
Housekeeping and Message Management Tools for Exchange Server
How to Save Email Messages to the Windows File System
 
VBA: Save Attachments to hard drive Can easily be tweaked to delete the attachment without saving it.
 
VBA: Attachments: Save the selection to the harddisk (VBOffice.net)
VBA: Attachments: Delete the selection (VBOffice.net)
How to use VBA code samples

Remove Attachments From Messages was last modified: November 25th, 2024 by Diane Poremsky

Related Posts:

  • Log Messages and Attachment Names
  • Add Attachment Names to Message Before Sending
  • Copy attachment names when replying
  • Use this macro to send an attachment to email addresses in the To line
    VBA: No attachments to CC'd recipients

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Subscribe
Notify of
27 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Patrick
March 27, 2023 9:16 pm

Hi, I try to delete the first image inside email template. I try with message.attachements(1).remove or message.attachements.remove 1 or things like that but all I get is empty frame, it seems to only remove source but not the object itself... Is there something to do? Thanks!

0
0
Reply
Darcy Douglas
July 15, 2019 4:19 pm

I've come across this macro, but like another post I'd like to only delete certain files, in my case .pdf attachments. What do I need to add? I'm a complete newbie, so kindly spell it out for me. :)

1
0
Reply
Keith
September 8, 2017 9:58 am

I used the code "DeleteAllAttachmentsFromSelectedMessages" in Outlook 2016 and although it deleted the attachments, Outlook's list still shows the paperclip symbol.
I also tried some VBA code from another website and it did the same in Outlook 2016, that one I used in Outlook 2007 and then the paperclip symbol disappeared.
Any ideas to rectify this problem ?

0
0
Reply
Diane Poremsky
Author
Reply to  Keith
September 8, 2017 10:33 pm

I don't have a solution right now, will need to look into it.

0
0
Reply
Diane Poremsky
Author
Reply to  Keith
September 8, 2017 10:45 pm

In a quick test, the paper clip was removed. What type of email account? What is your outlook build number? Does it happen with all attachments or just some?

0
0
Reply
Keith
Reply to  Diane Poremsky
September 12, 2017 9:14 am

My email account is IMAP, with a Yahoo email address.
Tried a few different tests and all were the same, the paperclip symbol remains.
Version Outlook 2016 MSO (16.0.8326.2096) 32 bit

0
0
Reply
Chris
December 21, 2016 3:41 pm

I made use of this script to great effect in my workflow. However, when a mailbox has multiple (nested) subfolders, navigating to each one, selecting all messages, and running the script becomes cumbersome. I took this script and modified it so that I could select the top level folder, and have it recurse into all subfolders and delete all messages' attachments. here is the modified code: ==================================================== Sub DeleteAllAttachmentsFromSelectedMessages() Dim oFolder As Outlook.Folder ' Set reference to the Selection. Can select a folder Set oFolder = ActiveExplorer.CurrentFolder ' this Sub must run in order to be recursive processFolder oFolder MsgBox "All Done. Attachments were removed.", vbOKOnly, "Message" Set oFolder = Nothing End Sub Private Sub processFolder(ByVal oParent As Outlook.Folder) Dim oMail As Outlook.MailItem Dim oAttachments As Attachments Dim lngAttachmentCount As Long ' Original selected folder as well as any recursed folders can contain mail. ' Iterate over all messages For Each oMail In oParent.Items ' Get list of Attachments for this message Set oAttachments = oMail.Attachments ' Get count of attachments for this message lngAttachmentCount = oAttachments.Count 'While there are attachments still remaining While lngAttachmentCount &gt; 0 oAttachments(1).Delete lngAttachmentCount = oAttachments.Count Wend 'save the message oMail.Save Next 'If there are… Read more »

0
0
Reply
Jeff
November 23, 2015 9:34 am

Hi, I receive numerous emails with attachments, some come with spreadsheets as well as the copy of the spreadsheet as a pdf, and others just come with the pdf. Normally, I send the pdf only on to other parties, but for those emails that include the spreadsheet, I have to remove the spreadsheet before I send the email on. Is there a macro I can use to eliminate the spreadsheet attachment only, if it exists. I currently use another macro I found on your site to send all the emails to a specific party, but now want to add this feature to remove any spreadsheets attached with the email and keep the pdf only to forward. thanks.

1
0
Reply
kjv1611
Reply to  Jeff
September 2, 2016 8:43 am

You'll need to add a couple of pieces to this code, shouldn't be too bad. You'll want to filter to those emails that have > 1 attachment probably or else look for a particular subject. Then you'll need to add another IF clause to check if the file type is Excel (I usually just look for excel like extensions).

So the general concept would be something like adding this around the delete section:

Outside/above this line:
While lngAttachmentCount > 0

Add something like:
If lngAttachmentCount > 1 Then 'Or you could say = 2, if you know it's only looking for exactly 2 attachments.

Then when you are looping through the attachments, it should be as simple as this or similar:
If oAttachments(1).Name Like "*.xl*" Then
' Do the delete
End If

This is just psuedo code more or less, as I've not tested a thing.

Thanks to Diane for sharing.

0
0
Reply
Viv
July 31, 2015 1:17 pm

Thank you! Just tried this today and it worked!

0
0
Reply
Kika Melo
June 25, 2015 2:58 am

Hi Diane. So sorry to bother you again, but any luck on getting to sort out my latest question of the 6th of May?

0
0
Reply
Diane Poremsky
Author
Reply to  Kika Melo
June 25, 2015 9:34 am

The way the macro on this page is written, it works on selected messages -
' Set reference to the Selection.
Set selItems = ActiveExplorer.Selection

' Loop though each item in the selection.
For Each myItem In selItems
Set myAttachments = myItem.Attachments

It's not going to go through all folders or all messages - you can select one or more messages and it will only apply to those. You can (and should) test it first by copying messages to a folder.

0
0
Reply
Kika Melo
May 16, 2015 5:08 am

Oh! In this case, I will patiently await your reply to my more complicated enquiry. Thanks, Diane!

0
0
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 30 Issue 31

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Jetpack plugin with Stats module needs to be enabled.
  • Move Deleted Items to Another Folder Automatically
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
  • New Outlook: Show To, CC, BCC in Replies
  • Insert Word Document into Email using VBA
  • Delete Empty Folders using PowerShell
  • Warn Before Deleting a Contact
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Move Deleted Items to Another Folder Automatically

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

New Outlook: Show To, CC, BCC in Replies

Insert Word Document into Email using VBA

Delete Empty Folders using PowerShell

Warn Before Deleting a Contact

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2025 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

:wpds_smile::wpds_grin::wpds_wink::wpds_mrgreen::wpds_neutral::wpds_twisted::wpds_arrow::wpds_shock::wpds_unamused::wpds_cool::wpds_evil::wpds_oops::wpds_razz::wpds_roll::wpds_cry::wpds_eek::wpds_lol::wpds_mad::wpds_sad::wpds_exclamation::wpds_question::wpds_idea::wpds_hmm::wpds_beg::wpds_whew::wpds_chuckle::wpds_silly::wpds_envy::wpds_shutmouth:
wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment