This Microsoft Visual Basic/Visual Basic for Applications example responds to the NewMail event by activating the explorer window. The sample code must be placed in a class module, and the Initialize_handlers routine must be called before the event procedure can be called by Microsoft Outlook.
Public WithEvents myOlApp As Outlook.Application
Public WithEvents myOlExp As Outlook.Explorer
Public Sub Initialize_handlers()
Set myOlApp = CreateObject("Outlook.Application")
Set myOlExp = myOlApp.ActiveExplorer
End Sub
Private Sub myOlApp_NewMail()
myOlExp.Activate
End Sub