N
Nigel RS
The following snippet of VBA code (Outlook 2003) is used to selectively
delete mail items from a selected mail folder. where the mail item subject
matches a predefined string (MailSubject). This code works great except it
fails to delete the last item. If there are 10 items matching it will delete
9 but leave one behind. If there is only 1 it fails to delete it.
If I step the code in the debugger it works! What could be causing this?
For Each objItem In objFolder.Items
' delete the item from the folder
If Left(objItem.Subject, mSubLen) = MailSubject Then
objItem.Delete
End If
Next
delete mail items from a selected mail folder. where the mail item subject
matches a predefined string (MailSubject). This code works great except it
fails to delete the last item. If there are 10 items matching it will delete
9 but leave one behind. If there is only 1 it fails to delete it.
If I step the code in the debugger it works! What could be causing this?
For Each objItem In objFolder.Items
' delete the item from the folder
If Left(objItem.Subject, mSubLen) = MailSubject Then
objItem.Delete
End If
Next