VBOffice

Delete Multiple Attachments at Once

Remove the attachments of several selected emails in one go.

Last modified: 2012/08/08 | Accessed: 11.401  | #94
◀ Previous sample Next sample ▶
Category-Manager Category-Manager
Access the master category list in the blink of an eye, share your color categories in a network, get a reminder service, and more.

Whether you select just one email or more, there's no function in Outlook to remove all the attachments at once.

This example lists the attachments by name and deletes them if you wish.


tip  How to add macros to Outlook
Public Sub DeleteAttachments2()
  Dim coll As VBA.Collection
  Dim obj As Object
  Dim Atts As Outlook.Attachments
  Dim Att As Outlook.Attachment
  Dim Sel As Outlook.Selection
  Dim i&, Msg$

  Set coll = New VBA.Collection

  If TypeOf Application.ActiveWindow Is Outlook.Inspector Then
    coll.Add Application.ActiveInspector.CurrentItem
  Else
    Set Sel = Application.ActiveExplorer.Selection
    For i = 1 To Sel.Count
      coll.Add Sel(i)
    Next
  End If

  For Each obj In coll
    Set Atts = obj.Attachments
    Msg = ""
    For i = Atts.Count To 1 Step -1
      Msg = Msg & Atts(i).FileName & vbCrLf
    Next
    If MsgBox(Msg, vbYesNo Or vbQuestion, "Delete?") = vbYes Then
      For i = Atts.Count To 1 Step -1
        Atts.Remove i
      Next
      obj.save
    End If
  Next
End Sub
Reporter Reporter
VBOffice Reporter is an easy to use tool for data analysis and reporting in Outlook. A single click, for instance, allows you to see the number of hours planned for meetings the next month.
email  Send a message