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
  #1  
Old August 16th 06, 09:38 PM posted to microsoft.public.outlook.program_vba
Ariel
external usenet poster
 
Posts: 10
Default deleting all messages in a folder

What code can I use to delete all messages in a folder (e.g. spam mail folder)?

Thanks in advance!
Ads
  #2  
Old August 17th 06, 07:55 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 Wed, 16 Aug 2006 12:38:01 -0700 schrieb Ariel:

Sample for the Junk folder:

Dim Items as OUtlook.Items
Set Items=Application.Session.GetDefaultFolder(olFolde rJunk).Items
While Items.Count
Items(1).Delete
Wend

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


What code can I use to delete all messages in a folder (e.g. spam mail

folder)?

Thanks in advance!

  #3  
Old August 18th 06, 03:18 AM posted to microsoft.public.outlook.program_vba
Ariel
external usenet poster
 
Posts: 10
Default deleting all messages in a folder

Hi Michael,

I am getting an error on the line:

Set Items = Application.Session.GetDefaultFolder(olFolderJunk) .Items

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

Help!!!

Thanks for your quick repsonse and assistance!



"Michael Bauer [MVP - Outlook]" wrote:

Am Wed, 16 Aug 2006 12:38:01 -0700 schrieb Ariel:

Sample for the Junk folder:

Dim Items as OUtlook.Items
Set Items=Application.Session.GetDefaultFolder(olFolde rJunk).Items
While Items.Count
Items(1).Delete
Wend

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


What code can I use to delete all messages in a folder (e.g. spam mail

folder)?

Thanks in advance!


  #4  
Old August 18th 06, 07: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 Thu, 17 Aug 2006 18:18:02 -0700 schrieb Ariel:

That´s a sampel for getting the Junk folder in OL 2003. If you use OL 2000
then you do not have that standard folder.

You need to know what folder you´re looking for. If it´s a subolder of the
Inbox e.g. then you could also write:

Dim Folder as Outlook.Folder
Dim Items as Outlook.Items

Set Folder=Application.Session.GetDefaultFolder(olFold erInbox)
Set Folder=Folder.Folders("name")
Set Items=Folder.Items

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


Hi Michael,

I am getting an error on the line:

Set Items = Application.Session.GetDefaultFolder(olFolderJunk) .Items

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

are
not valid."

Help!!!

Thanks for your quick repsonse and assistance!



"Michael Bauer [MVP - Outlook]" wrote:

Am Wed, 16 Aug 2006 12:38:01 -0700 schrieb Ariel:

Sample for the Junk folder:

Dim Items as OUtlook.Items
Set Items=Application.Session.GetDefaultFolder(olFolde rJunk).Items
While Items.Count
Items(1).Delete
Wend

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


What code can I use to delete all messages in a folder (e.g. spam mail

folder)?

Thanks in advance!


  #5  
Old August 18th 06, 05:24 PM posted to microsoft.public.outlook.program_vba
Ariel
external usenet poster
 
Posts: 10
Default deleting all messages in a folder

Guten tag, Michael.

I am using Outlook 2003. The Spam folder is a folder under Personal Folders.
This code does not appear to find that folder, and thus it ends without doing
anything.

Danke,

Ariel

"Michael Bauer [MVP - Outlook]" wrote:

Am Thu, 17 Aug 2006 18:18:02 -0700 schrieb Ariel:

That´s a sampel for getting the Junk folder in OL 2003. If you use OL 2000
then you do not have that standard folder.

You need to know what folder you´re looking for. If it´s a subolder of the
Inbox e.g. then you could also write:

Dim Folder as Outlook.Folder
Dim Items as Outlook.Items

Set Folder=Application.Session.GetDefaultFolder(olFold erInbox)
Set Folder=Folder.Folders("name")
Set Items=Folder.Items

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


Hi Michael,

I am getting an error on the line:

Set Items = Application.Session.GetDefaultFolder(olFolderJunk) .Items

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

are
not valid."

Help!!!

Thanks for your quick repsonse and assistance!



"Michael Bauer [MVP - Outlook]" wrote:

Am Wed, 16 Aug 2006 12:38:01 -0700 schrieb Ariel:

Sample for the Junk folder:

Dim Items as OUtlook.Items
Set Items=Application.Session.GetDefaultFolder(olFolde rJunk).Items
While Items.Count
Items(1).Delete
Wend

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


What code can I use to delete all messages in a folder (e.g. spam mail
folder)?

Thanks in advance!


  #6  
Old August 19th 06, 09:16 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 Fri, 18 Aug 2006 08:24:51 -0700 schrieb Ariel:

Hallo Ariel,

does the latter sample raise the same error? Where do you insert that code,
is it the module ThisOutlookSession (VBA) or a custom form (VBS)?

In VBS the constants are unknown, instead use their values directly; for
olFolderJunk it´s 23, for olFolderInbox it´s 11.

Here´s a samle for getting folders by their path:
www.outlookcode.com/d/code/getfolder.htm

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


Guten tag, Michael.

I am using Outlook 2003. The Spam folder is a folder under Personal

Folders.
This code does not appear to find that folder, and thus it ends without

doing
anything.

Danke,

Ariel

"Michael Bauer [MVP - Outlook]" wrote:

Am Thu, 17 Aug 2006 18:18:02 -0700 schrieb Ariel:

That´s a sampel for getting the Junk folder in OL 2003. If you use OL

2000
then you do not have that standard folder.

You need to know what folder you´re looking for. If it´s a subolder of

the
Inbox e.g. then you could also write:

Dim Folder as Outlook.Folder
Dim Items as Outlook.Items

Set Folder=Application.Session.GetDefaultFolder(olFold erInbox)
Set Folder=Folder.Folders("name")
Set Items=Folder.Items

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


Hi Michael,

I am getting an error on the line:

Set Items = Application.Session.GetDefaultFolder(olFolderJunk) .Items

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

are
not valid."

Help!!!

Thanks for your quick repsonse and assistance!



"Michael Bauer [MVP - Outlook]" wrote:

Am Wed, 16 Aug 2006 12:38:01 -0700 schrieb Ariel:

Sample for the Junk folder:

Dim Items as OUtlook.Items
Set Items=Application.Session.GetDefaultFolder(olFolde rJunk).Items
While Items.Count
Items(1).Delete
Wend

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


What code can I use to delete all messages in a folder (e.g. spam mail
folder)?

Thanks in advance!


  #7  
Old August 20th 06, 11:56 PM posted to microsoft.public.outlook.program_vba
Ariel
external usenet poster
 
Posts: 10
Default deleting all messages in a folder

Hi Michael,

I am placing the code in the ThisOutlookSession module, so I assume that the
path is "Personal Folders\Spam."

I am not getting any error message now, but nothing is happening?

Thanks for your help.

Ariel

"Michael Bauer [MVP - Outlook]" wrote:

Am Fri, 18 Aug 2006 08:24:51 -0700 schrieb Ariel:

Hallo Ariel,

does the latter sample raise the same error? Where do you insert that code,
is it the module ThisOutlookSession (VBA) or a custom form (VBS)?

In VBS the constants are unknown, instead use their values directly; for
olFolderJunk it´s 23, for olFolderInbox it´s 11.

Here´s a samle for getting folders by their path:
www.outlookcode.com/d/code/getfolder.htm

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


Guten tag, Michael.

I am using Outlook 2003. The Spam folder is a folder under Personal

Folders.
This code does not appear to find that folder, and thus it ends without

doing
anything.

Danke,

Ariel

"Michael Bauer [MVP - Outlook]" wrote:

Am Thu, 17 Aug 2006 18:18:02 -0700 schrieb Ariel:

That´s a sampel for getting the Junk folder in OL 2003. If you use OL

2000
then you do not have that standard folder.

You need to know what folder you´re looking for. If it´s a subolder of

the
Inbox e.g. then you could also write:

Dim Folder as Outlook.Folder
Dim Items as Outlook.Items

Set Folder=Application.Session.GetDefaultFolder(olFold erInbox)
Set Folder=Folder.Folders("name")
Set Items=Folder.Items

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


Hi Michael,

I am getting an error on the line:

Set Items = Application.Session.GetDefaultFolder(olFolderJunk) .Items

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

Help!!!

Thanks for your quick repsonse and assistance!



"Michael Bauer [MVP - Outlook]" wrote:

Am Wed, 16 Aug 2006 12:38:01 -0700 schrieb Ariel:

Sample for the Junk folder:

Dim Items as OUtlook.Items
Set Items=Application.Session.GetDefaultFolder(olFolde rJunk).Items
While Items.Count
Items(1).Delete
Wend

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


What code can I use to delete all messages in a folder (e.g. spam mail
folder)?

Thanks in advance!



  #8  
Old August 21st 06, 06:39 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 Sun, 20 Aug 2006 14:56:02 -0700 schrieb Ariel:

Ariel, please walk through the code execution step by step (F8) and watch
what happens. Don´t use an "On Error Resume Next" statement for debugging.

It all depends on that the folder will be found, so you don´t need to
"assume" but to know the folder :-)

BTW: Any folder named "Spam" is not the default Junk Folder.

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


Hi Michael,

I am placing the code in the ThisOutlookSession module, so I assume that

the
path is "Personal Folders\Spam."

I am not getting any error message now, but nothing is happening?

Thanks for your help.

Ariel

"Michael Bauer [MVP - Outlook]" wrote:

Am Fri, 18 Aug 2006 08:24:51 -0700 schrieb Ariel:

Hallo Ariel,

does the latter sample raise the same error? Where do you insert that

code,
is it the module ThisOutlookSession (VBA) or a custom form (VBS)?

In VBS the constants are unknown, instead use their values directly; for
olFolderJunk it´s 23, for olFolderInbox it´s 11.

Here´s a samle for getting folders by their path:
www.outlookcode.com/d/code/getfolder.htm

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


Guten tag, Michael.

I am using Outlook 2003. The Spam folder is a folder under Personal

Folders.
This code does not appear to find that folder, and thus it ends without

doing
anything.

Danke,

Ariel

"Michael Bauer [MVP - Outlook]" wrote:

Am Thu, 17 Aug 2006 18:18:02 -0700 schrieb Ariel:

That´s a sampel for getting the Junk folder in OL 2003. If you use OL

2000
then you do not have that standard folder.

You need to know what folder you´re looking for. If it´s a subolder of

the
Inbox e.g. then you could also write:

Dim Folder as Outlook.Folder
Dim Items as Outlook.Items

Set Folder=Application.Session.GetDefaultFolder(olFold erInbox)
Set Folder=Folder.Folders("name")
Set Items=Folder.Items

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


Hi Michael,

I am getting an error on the line:

Set Items = Application.Session.GetDefaultFolder(olFolderJunk) .Items

Stating "Could not complete the operation. One or more parameter

values
are
not valid."

Help!!!

Thanks for your quick repsonse and assistance!



"Michael Bauer [MVP - Outlook]" wrote:

Am Wed, 16 Aug 2006 12:38:01 -0700 schrieb Ariel:

Sample for the Junk folder:

Dim Items as OUtlook.Items
Set Items=Application.Session.GetDefaultFolder(olFolde rJunk).Items
While Items.Count
Items(1).Delete
Wend

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


What code can I use to delete all messages in a folder (e.g. spam

mail
folder)?

Thanks in advance!



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

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!

"Michael Bauer [MVP - Outlook]" wrote:

Am Sun, 20 Aug 2006 14:56:02 -0700 schrieb Ariel:

Ariel, please walk through the code execution step by step (F8) and watch
what happens. Don´t use an "On Error Resume Next" statement for debugging.

It all depends on that the folder will be found, so you don´t need to
"assume" but to know the folder :-)

BTW: Any folder named "Spam" is not the default Junk Folder.

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


Hi Michael,

I am placing the code in the ThisOutlookSession module, so I assume that

the
path is "Personal Folders\Spam."

I am not getting any error message now, but nothing is happening?

Thanks for your help.

Ariel

"Michael Bauer [MVP - Outlook]" wrote:

Am Fri, 18 Aug 2006 08:24:51 -0700 schrieb Ariel:

Hallo Ariel,

does the latter sample raise the same error? Where do you insert that

code,
is it the module ThisOutlookSession (VBA) or a custom form (VBS)?

In VBS the constants are unknown, instead use their values directly; for
olFolderJunk it´s 23, for olFolderInbox it´s 11.

Here´s a samle for getting folders by their path:
www.outlookcode.com/d/code/getfolder.htm

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


Guten tag, Michael.

I am using Outlook 2003. The Spam folder is a folder under Personal
Folders.
This code does not appear to find that folder, and thus it ends without
doing
anything.

Danke,

Ariel

"Michael Bauer [MVP - Outlook]" wrote:

Am Thu, 17 Aug 2006 18:18:02 -0700 schrieb Ariel:

That´s a sampel for getting the Junk folder in OL 2003. If you use OL
2000
then you do not have that standard folder.

You need to know what folder you´re looking for. If it´s a subolder of
the
Inbox e.g. then you could also write:

Dim Folder as Outlook.Folder
Dim Items as Outlook.Items

Set Folder=Application.Session.GetDefaultFolder(olFold erInbox)
Set Folder=Folder.Folders("name")
Set Items=Folder.Items

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


Hi Michael,

I am getting an error on the line:

Set Items = Application.Session.GetDefaultFolder(olFolderJunk) .Items

Stating "Could not complete the operation. One or more parameter

values
are
not valid."

Help!!!

Thanks for your quick repsonse and assistance!



"Michael Bauer [MVP - Outlook]" wrote:

Am Wed, 16 Aug 2006 12:38:01 -0700 schrieb Ariel:

Sample for the Junk folder:

Dim Items as OUtlook.Items
Set Items=Application.Session.GetDefaultFolder(olFolde rJunk).Items
While Items.Count
Items(1).Delete
Wend

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


What code can I use to delete all messages in a folder (e.g. spam

mail
folder)?

Thanks in advance!




  #10  
Old August 21st 06, 08:49 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

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!


 




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 09:45 AM.


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.