
Emptying Outlook Deleted Items Folder.
Siva,
This example uses CDO to clean out the trash folder and is written in
VBScript as a Windows Script Host script.
Here you go:
--
Dim oSession, oTrash, oItem
Set oSession = CreateObject("MAPI.Session")
oSession.Logon
Set oTrash = oSession.GetDefaultFolder( 4 ) ' the Deleted Items folder
wScript.Echo "There are " & oTrash.Messages.Count & " messages in folder"
for each oItem in oTrash.Messages
wScript.Echo vbTab & oItem.Subject
next
'Delete all messages
wScript.Echo "Deleting messages..."
oTrash.Messages.Delete
wScript.Echo "There are now " & oTrash.Messages.Count & " messages in
folder"
Set oTrash = Nothing
oSession.Logoff
Set oSession = Nothing
--
If you're using Outlook 2000, I would recommend writing this using the
Outlook object model rather than CDO. I haven't done any Outlook 2000
development, so I can't help you too much. The couple of things I can tell
you is that the Deleted Items folder is 3 in the Outlook object model
instead of 4 and that you would use the Items collection, not the Messages
collection. I also don't think there's a simple one liner like
'oTrash.Messages.Delete', you may have to delete each message individually.
Matt.
Quote:
> All,
> Could any one help me out on how I can automatically empty deleted items
> folder in MS Outlook?
> I am looking for script that would monitor the Deleted Items folder and
> delete in on a set interval.
> Thanks for any help