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

emptying the deleted items folder



 
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old March 20th 06, 08:25 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default emptying the deleted items folder

Do not use "for" or r"for each" loop, loop from count down to 1 instead:

for i = cdo_items.count to 1 step -1
....

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"billp" wrote in message
...
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



 




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
Deleted Items Folder AAH Outlook Express 5 March 10th 06 09:56 PM
Deleted email not going to Deleted Items folder techie_comps Outlook - General Queries 1 February 27th 06 04:59 PM
Deleted items not emptying David H Outlook Express 4 February 11th 06 11:26 AM
Recover deleted messages after emptying deleted items folder Gail Outlook Express 2 January 30th 06 05:18 PM
Message goes to Deleted Items folder instead of Inbox folder needhelp Outlook Express 3 January 17th 06 04:49 PM


All times are GMT +1. The time now is 02:35 AM.


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