A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

deleting all messages in a folder



 
 
Thread Tools Search this Thread Display Modes
  #11  
Old August 22nd 06, 12:35 AM posted to microsoft.public.outlook.program_vba
Ariel
external usenet poster
 
Posts: 10
Default deleting all messages in a folder

I got the same error.

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

Try olFolderJunk. There is no enum member olFolderSpam.

--
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
...
Hi Michael,

When walking through the code, it fails at that same line as befo

Set Folder = Application.Session.GetDefaultFolder(olFolderSpam)

I assume that you believe that it has to do with not finding the correct
folder?

Will the function you gave me tell me this? If so, how do I run this
within
Outlook (I am an advanced programmer in VBA for access and excel, but
outlook
is a different animal).

Thanks for your continued support!



Ads
  #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.


  #13  
Old August 22nd 06, 06:41 AM posted to microsoft.public.outlook.program_vba
Ariel
external usenet poster
 
Posts: 10
Default deleting all messages in a folder

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.



  #14  
Old August 22nd 06, 07:23 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default deleting all messages in a folder

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.



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



  #16  
Old August 22nd 06, 09:09 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default deleting all messages in a folder

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

Please copy the GetFolder function into the module ThisOutlookSession. Then
you can call it from within the sample Ken gave you with:

Set objFolder = GetFolder("Personal Folders/Inbox")

Please ensure that the path exists respectively edit the path.

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


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.



  #17  
Old August 22nd 06, 04:10 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default deleting all messages in a folder

Michael,

It almost sounds like something is buggered in her PST file. Maybe running
ScanPST.exe a couple of times with Outlook closed and then opening Outlook
with the /resetfolders switch (Start, Run dialog: outlook.exe /resetfolders)
might be useful. It can't hurt and may help.

Other than that it's off to OutlookSpy to see if the default Store has the
correct EntryID references for the default folders.

This is for the default PST file?

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


"Michael Bauer [MVP - Outlook]" wrote in message
...
Am Mon, 21 Aug 2006 22:51:02 -0700 schrieb Ariel:

Please copy the GetFolder function into the module ThisOutlookSession.
Then
you can call it from within the sample Ken gave you with:

Set objFolder = GetFolder("Personal Folders/Inbox")

Please ensure that the path exists respectively edit the path.

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


  #18  
Old August 22nd 06, 04:54 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default deleting all messages in a folder

Am Tue, 22 Aug 2006 10:10:07 -0400 schrieb Ken Slovak - [MVP - Outlook]:

Good point, Ken. I never experienced that a default folder canīt be found.

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


Michael,

It almost sounds like something is buggered in her PST file. Maybe running
ScanPST.exe a couple of times with Outlook closed and then opening Outlook
with the /resetfolders switch (Start, Run dialog: outlook.exe

/resetfolders)
might be useful. It can't hurt and may help.

Other than that it's off to OutlookSpy to see if the default Store has the
correct EntryID references for the default folders.

This is for the default PST file?

  #19  
Old August 22nd 06, 07:22 PM posted to microsoft.public.outlook.program_vba
Ariel
external usenet poster
 
Posts: 10
Default deleting all messages in a folder

Michael and Ken,

I tried the function but it errored out on a type mismatch.

I will run the scanPST as Michael suggests and try this again. I have
Outlook Spy loaded, so if you tell me where to look for the folder code, I
can try and retrieve it

Thanks again, guys

Ariel

"Michael Bauer [MVP - Outlook]" wrote:

Am Tue, 22 Aug 2006 10:10:07 -0400 schrieb Ken Slovak - [MVP - Outlook]:

Good point, Ken. I never experienced that a default folder canÂīt be found.

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


Michael,

It almost sounds like something is buggered in her PST file. Maybe running
ScanPST.exe a couple of times with Outlook closed and then opening Outlook
with the /resetfolders switch (Start, Run dialog: outlook.exe

/resetfolders)
might be useful. It can't hurt and may help.

Other than that it's off to OutlookSpy to see if the default Store has the
correct EntryID references for the default folders.

This is for the default PST file?


  #20  
Old August 22nd 06, 08:15 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default deleting all messages in a folder

What line produced the error?

--
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
...
Michael and Ken,

I tried the function but it errored out on a type mismatch.

I will run the scanPST as Michael suggests and try this again. I have
Outlook Spy loaded, so if you tell me where to look for the folder code, I
can try and retrieve it

Thanks again, guys

Ariel


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
download messages without deleting messages on server problem Eric Outlook - Installation 1 March 21st 06 07:21 PM
deleting downloaded messages from newsgroups R..VENKATARAMAN Outlook Express 4 March 21st 06 05:24 AM
Deleting messages in Outlook XP Dean Outlook - General Queries 1 March 14th 06 02:23 PM
OE EXP. 6.0 Deleting Messages ralphS Outlook Express 1 February 15th 06 08:45 PM
deleting messages Shanny Outlook Express 3 January 18th 06 05:44 PM


All times are GMT +1. The time now is 03:16 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright Đ2004-2025 Outlook Banter.
The comments are property of their posters.