Delete Attachments - Just Shy of Solution

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top