FolderAdd Event

Microsoft Outlook Visual Basic

Occurs when a folder is added to the specified Folders collection. This event is not available in Microsoft Visual Basic Scripting Edition (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

The following Microsoft Visual Basic/Visual Basic for Applications (VBA) 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