View Single Post
  #12  
Old August 22nd 06, 12:57 AM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default deleting all messages in a folder

Take this code and place it either in ThisOutlookSession or in a code
module. Place your cursor in the procedure and press F5 to run it. Report
back what happens.

Public Sub DeleteAllJunk()
Dim oFolder As Outlook.MAPIFolder
Dim colItems As Outlook.Items
Dim oItem As Object
Dim i As Long

Set oFolder = Application.Session.GetDefaultFolder(olFolderJunk)
Set colItems = oFolder.Items
If colItems.Count 0 Then
For i = colItems.Count To 1 Step -1
Set oItem = colItems.Item(i)
oItem.Delete
Next i
End If
End Sub

--
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


"Ariel" wrote in message
...
I got the same error.


Ads