View Single Post
  #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!



Ads