View Single Post
  #1  
Old March 20th 06, 08:08 PM posted to microsoft.public.outlook.program_vba
billp
external usenet poster
 
Posts: 4
Default emptying the deleted items folder

I have the script below to perform a hard delete on items in the deleted
items folder. I have it scheduled aa a task but it only deletes 10 or 20
emails.

' Antonio Gonzalez 3.2.2006, 3.6.2006
' This is a sample script, provided as is without warranty.
' Sample scripts are not intended to run in a production environment.
'
' Microsof Corporation.

Option Explicit

Const cdoDefaultFolderCalendar = 0
Const cdoDefaultFolderContacts = 5
Const cdoDefaultFolderDeletedItems = 4
Const cdoDefaultFolderInbox = 1
Const cdoDefaultFolderJournal = 6
Const cdoDefaultFolderNotes = 7
Const cdoDefaultFolderOutbox = 2
Const cdoDefaultFolderSentItems = 3
Const cdoDefaultFolderTasks = 8

Dim ie_application, document
Dim cdo_session, cdo_folder, cdo_items, cdo_item
Dim servername, profilename, profileinfo, vbsLineFeed

vbsLineFeed = Chr(10)

Set ie_application = WScript.CreateObject("InternetExplorer.Application ")

With (ie_application)

.Top = 45
.Left = 45
.Width = 500
.Height = 250
.Resizable = False
.StatusBar = True
.AddressBar = False
.ToolBar = False
.MenuBar = False

Do While (.Busy)

WScript.Sleep 500

Loop

.Navigate "about:blank"
.Visible = True

Set document = .Document

End With

document.open
document.writeln "html"
document.writeln "head"
document.writeln "titleSRX060227604215/title"
document.writeln "script language=""javascript"""
document.writeln "!--"
document.writeln "defaultStatus = document.title"
document.writeln "' --"
document.writeln "/script"
document.writeln "/head"
document.writeln "body bgcolor=""#ffffff"""
document.body.style.cursor = "wait"
document.writeln "pProcessing request, please wait.../p"

ie_application.StatusText = "Connecting to server..."

servername = "sbke2kdev01"
profilename = "PowersB"
profileinfo = servername & vbsLineFeed & profilename

Set cdo_session = WScript.CreateObject("MAPI.Session")
cdo_session.Logon "", "", False, False, 0, True, profileinfo

Set cdo_folder = cdo_session.GetDefaultFolder(cdoDefaultFolderDelet edItems)
Set cdo_items = cdo_folder.Messages

For Each cdo_item In cdo_items

document.writeln "* "

ie_application.StatusText = "Deleting: " & cdo_item.Subject '& " from " &
cdo_folder.Name

cdo_item.Delete False

Next

cdo_session.Logoff

Set cdo_item = Nothing
Set cdo_items = Nothing
Set cdo_folder = Nothing
Set cdo_session = Nothing

document.writeln "pRequest completed successfully./p"
document.body.style.cursor = "default"
document.writeln "/body"
document.writeln "/html"
document.close

WScript.Sleep 4000

ie_application.Quit
Ads