How do I find my PST tree?

  • Thread starter Thread starter Mike Crofut
  • Start date Start date
M

Mike Crofut

I've stolen code from elsewhere to make a simple routine to empty my default
deleted items folder. I have another deleted items folder in my PST tree
that I'd like to navigate to and also empty. Here is the code I have now:

Sub clearDeletefolder()
Dim Deleteditems As Object
Set Deleteditems =
Outlook.GetNamespace("Mapi").GetDefaultFolder(olFolderDeletedItems).Items
Do Until Deleteditems.Count = 0
Deleteditems.Item(Deleteditems.Count).Delete
Loop
Set Deleteditems = Nothing
End Sub
 
You can do that easily in Extended MAPI or CDO by reading the
PR_IPM_WASTEBASKET_ENTRYID from each message store and and using it to open
the corresponding folder.
In Outlook Object Model your only workaround is to loop through all top
level folders using Namespace.Folders collection, then for each folder try
to retrieve a "Deleted Items" subfolder:

for i= 1 to Namespace.Folders.Count
set DelItemsFolder = Namespace.Folders(i).Folders("Deleted Items")
next

the problem is the folder name ("Deleted Items") is locale specific.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Thanks. I don't have CDO installed or tools to do extended MAPI on my
corporate PC, but your suggestion for looping through the collection until I
found the folder I wanted worked great. I can now empty both deleted items
folders with one button click.
 
Back
Top