FolderRemove Event

Microsoft Outlook Visual Basic

FolderRemove Event

       

Occurs when a folder is removed from the specified Folders collection. This event is not available in VBScript.

Sub object_FolderRemove()

object   An expression that evaluates to a Folders collection object.

Example

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