FolderAdd Event

Microsoft Outlook Visual Basic

FolderAdd Event

       

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

Sub object_FolderAdd(ByVal Folder As MAPIFolder)

object   An expression that evaluates to a Folders collection object.

Folder   Required. The MAPIFolder that was added to the collection.

Example

This example displays a new folder created in the user’s Inbox folder.

Dim myOlApp As New Outlook.Application
Public WithEvents myOlFolders As Outlook.Folders

Public Sub Initialize_handler()
    Set myOlFolders = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders
End Sub

Private Sub myOlFolders_FolderAdd(ByVal Folder As Outlook.MAPIFolder)
    Folder.Display
End Sub