This example fills a combo box on a form with the names of the folders in the Deleted Items folder. The sample code must be placed in a class module, and the Initialize_handler
routine must be called before the event procedure can be called by Microsoft Outlook.
Dim myolapp As New Outlook.Application
Dim WithEvents myFolders As Outlook.Folders
Sub Initialize_handler()
Set myNS = myolapp.GetNamespace("MAPI")
Set myFolders = myNS.GetDefaultFolder(olFolderDeletedItems).Folders
End Sub
Private Sub myFolders_FolderRemove()
Form1.Combo1.Clear
For x = 1 To myFolders.Count
Form1.Combo1.AddItem (myFolders.Item(x).Name)
Next x
End Sub