View Single Post
  #8  
Old June 13th 06, 12:10 PM posted to microsoft.public.outlook.program_vba
Joanne
external usenet poster
 
Posts: 12
Default verify and delete mailitem

Sue
Thanks so much for your input on my little project. I always have
great appreciation for the time and expertise you mvps donate to us
wannabes.
Your code is so precise - I love it.
Also, have spent much time on your outlookcode.com - will spend much
more also - so much to learn and absorb from there.
Keep up the great work

I'm a big fan of this newsgroup
Joanne

Sue Mosher [MVP-Outlook] wrote:

Selection.Find is Word's method for searching inside text. Inside an Outlook item, you would use the Instr() function to test for a match inside the MailItem.Body

If Instr(obj.Body, "Description: Successful" 0 Then
obj.Delete
End If

The tricky part is how your construct the loop. Because the index changes each time you delete an item, you can't use a For Each ... Next loop, but can instead us a countdown loop:

count = Items.Count
For i = count to 1 Step -1
Set obj = Items(i)
If Instr(obj.Body, "Description: Successful" 0 Then
obj.Delete
End If
Next

You can put the code in ThisOutlookSession or create a new module, which would make it easier to export for backup.



Ads