I have written a macro (based on code that BlueDevilFan supplied here) to automatically empty the deleted items folder. However it works on a machine with Outlook 2007 installed, it wouldn't work on a machine that had Outlook 2003 installed.
With 2003 I discovered that it would only delete some items (say 1 or 2). Nothing further happened.
However when I ran the code in the VBE editor, by pressing F5 I got a message stating that outlook was unable to remove the file, or that it didn't exist or that I didn't have permission.
When i did a MSGBOX in the routine to return (via Count) the number of items, the right number of items were coming up.
Has anybody else experienced this problem or can they suggest a solution ? Thanks
'empty the junk e-mail folder
Call Empty_Folder("Junk E-mail")
'empty the deleted items folder
Call Empty_Folder("Deleted Items")
Sub Empty_Folder(Folder_Name As String)
Dim olkFolder As Outlook.MAPIFolder, _
olkItem As Object, _
intIndex As Integer
Set olkFolder = Session.GetDefaultFolder(olFolderInbox).Parent.Folders(Folder_Name)
For intIndex = olkFolder.Items.Count To 1 Step -1
Set olkItem = olkFolder.Items.Item(intIndex)
Set olkFolder = Nothing
Set olkItem = Nothing