0

first i use this code for delete the all attachment in outlook

 For i = 1 To oMail.Attachments.Count

      oMail.Attachments.Remove(i)

 Next

i have 4 attachment it remove but i check the oMail.Attachments.Count it display 2

After i search in stack forum this code

For Each a As outlook.Attachment In oMail.Attachments

   a.Delete()

Next

it delete the 1 & 3 attachment but not delete the 2 & 4 attachment

akhil kumar
  • 1,598
  • 1
  • 13
  • 26
  • Possible duplicate of [For Each loop: Some items get skipped when looping through Outlook mailbox to delete items](http://stackoverflow.com/questions/10725068/for-each-loop-some-items-get-skipped-when-looping-through-outlook-mailbox-to-de) – niton Dec 18 '15 at 17:25

1 Answers1

0

Try the below;

If oMail.Attachments.Count > 0 Then

  For i = oMail.Attachments.Count To 1 Step -1

   ' Delete the attachment.
   oMail.Attachments.Item(i).Delete

  Next i
  oMail.Save

End If

This LINK might give you some more details.

Nadeem_MK
  • 7,533
  • 7
  • 50
  • 61