Delete Attachments - Just Shy of Solution

  • Thread starter Thread starter Access101
  • Start date Start date
A

Access101

I select 3 emails, all of which have attachments. The code loops through and
sees all 3 emails, but only removes attachments from the 1st one. Any help
is appreciated.

Dim objOutlook As Outlook.Application
Dim objMsg As Object
Dim objAttachments As Outlook.Attachments
Dim objSelectedItems As Outlook.Selection
Dim i As Long, lngCounter As Long

Set objOutlook = CreateObject("Outlook.Application")
Set objSelectedItems = objOutlook.ActiveExplorer.Selection

For Each objMsg In objSelectedItems

If objMsg.Class = olMail Then

Set objAttachments = objMsg.Attachments
lngCounter = objAttachments.Count

If lngCounter > 0 Then

For i = lngCounter To 1 Step -1
objAttachments.Item(i).Delete
Next i

End If
End If

Next
 
Back
Top