View Single Post
  #15  
Old August 22nd 06, 07:51 AM posted to microsoft.public.outlook.program_vba
Ariel
external usenet poster
 
Posts: 10
Default deleting all messages in a folder

I just got the same error again.

Please tell me how to run the function. Does it need to be imbedded within a
sub routine or can it be run on its own like in excel or access?

"Michael Bauer [MVP - Outlook]" wrote:

Am Mon, 21 Aug 2006 21:41:02 -0700 schrieb Ariel:

That´s really weird. Just to be su Please replace the constant
olFolderJunk by its value (23).

Did you try the mentioned GetFolder function? What happens if you pass the
path?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


Hi Ken,

I placed the routine in ThisOutlookSession and got the same error as

always

"Could not complete the operation. One or more parameter values are
not valid."

There is a Junk folder and it is sub folder under Personal Folders, so I
don't understand why this is not working :-(

Thanks for your help...

Ariel

"Ken Slovak - [MVP - Outlook]" wrote:

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