Previous Thread:   How to write a macro?

9/27/2005 5:51:55 AM    Re: Deleting items in public folder
The problem is within the For/Each loop.  Basically it is going to process  
  
every other item because the instant a delete is issued, the items  
  
collection is reordered.  You need to rewrite the loop so it process the  
  
items in a descending order.  
  
"Maria Jensen" <nesnejairam@hotmail.com> wrote in message  
  
news:O18rW10wFHA.3588@tk2msftngp13.phx.gbl...



9/27/2005 12:22:11 PM    Deleting items in public folder
Hi there,  
  
I have a curious situation. I want the user to pick a folder, do stuff with  
  
each item in the folder and then delete the item (not the folder). When I  
  
try this, it seems that I only get through half the folder, then it exits.  
  
That means that only half the messages are deleted. If I just run through  
  
the folder without doing Item.Delete, my code runs through all items.  
  
Now, the folder chosen is a public folder - I have a feeling that perhaps  
  
that has something to do with this problem.  
  
Can anyone help?  
  
This is my code:  
  
Set oApp = New Outlook.Application  
  
Set oNamespace = oApp.GetNamespace("MAPI")  
  
Set oFolder = oNamespace.PickFolder  
  
If Not oFolder Is Nothing Then  
  
MsgBox "No of mails: " & oFolder.Items.Count  
  
For Each Item In oFolder.Items  
  
---- Doing stuff -----  
  
Item.Delete  
  
Next  
  
End If

9/27/2005 3:49:38 PM    Re: Deleting items in public folder
Processing the items in descending order solved the problem. Thank you very  
  
much  
  
"neo [mvp outlook]" <neo@online.mvps.org> wrote in message  
  
news:uche%23I2wFHA.900@TK2MSFTNGP11.phx.gbl...