Skip to content

Instantly share code, notes, and snippets.

@fwojciec
Created June 20, 2018 14:51
Show Gist options
  • Save fwojciec/824a62354766bf984a9a645f4b2cf7db to your computer and use it in GitHub Desktop.
Save fwojciec/824a62354766bf984a9a645f4b2cf7db to your computer and use it in GitHub Desktop.
RemoveAttachments
Sub RemoveAttachments()
Dim objSelection As Outlook.Selection
Dim i, n As Long
Dim objMail As Outlook.MailItem
Dim objAttachment As Outlook.Attachment
'Get the selected emails
Set objSelection = Outlook.Application.ActiveExplorer.Selection
'Process each email one by one
For i = objSelection.Count To 1 Step -1
If TypeOf objSelection(i) Is MailItem Then
Set objMail = objSelection(i)
If objMail.Attachments.Count > 0 Then
For n = objMail.Attachments.Count To 1 Step -1
Set objAttachment = objMail.Attachments.Item(n)
objAttachment.Delete
Next
objMail.Save
End If
End If
Next i
End Sub
@fwojciec
Copy link
Author

fwojciec commented Jun 20, 2018

Microsoft Outlook Macro -- removes all attachments from all selected emails.
Adapted from: https://www.datanumen.com/blogs/batch-remove-specific-type-attachments-multiple-outlook-emails/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment