The macro below deletes all of the items that get routed to a junk mail
folder and then deletes (empties) the Delete folder (OL 2003). Most of the
time it works just fine, but sometimes it will not empty the Delete folder.
Instead it may delete one item in the delete folder. Repeated runs will
delete addtional items one at a time.
Anyone see what it is about this code that might contribute to this kind of
behavior?
One suggestion I've tried is following:
replacing these lines
For lngE = .Folders(lngD).Items.Count To 1 Step -1
.Folders(lngD).Items(lngE).Delete
Next lngE
with this
With .Folders(lngD)
do while .items.Count > 0
.items(1).delete
Loop
End with
This works as well only now I often have to run the macro twice to empty the
delete folder. The first time nothing happens; the second time it works
fine.

Signature
Colonel Blip
colonel.blip@nospambigfoot.com
Remove "nospam" when replying.
__________________________________
Sub ClearAllDeletedItems()
Dim olNS As Outlook.NameSpace
Dim collInfoStores As Outlook.Folders
Dim lngC As Long, lngD As Long, lngE As Long
Set olNS = Application.GetNamespace("MAPI")
Set collInfoStores = olNS.Folders
For lngC = 1 To collInfoStores.Count
With collInfoStores(lngC)
For lngD = 1 To .Folders.Count
If CBool(.Folders(lngD).Items.Count) And _
.Folders(lngD).Name = "Junk E-mail" Then
For lngE = .Folders(lngD).Items.Count To 1 Step -1
.Folders(lngD).Items(lngE).Delete
Next lngE
End If
Next lngD
End With
Next lngC
For lngC = 1 To collInfoStores.Count
With collInfoStores(lngC)
For lngD = 1 To .Folders.Count
If CBool(.Folders(lngD).Items.Count) And _
.Folders(lngD).Name = "Deleted Items" Then
For lngE = .Folders(lngD).Items.Count To 1 Step -1
.Folders(lngD).Items(lngE).Delete
Next lngE
End If
Next lngD
End With
Next lngC
Set collInfoStores = Nothing
Set olNS = Nothing
End Sub
Ken Slovak - [MVP - Outlook] - 05 Aug 2004 17:22 GMT
I'd use a variable to get .Count and get each item and use its Delete
method. See if that helps.

Signature
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
> The macro below deletes all of the items that get routed to a junk mail
> folder and then deletes (empties) the Delete folder (OL 2003). Most of the
[quoted text clipped - 24 lines]
> delete folder. The first time nothing happens; the second time it works
> fine.