Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

Inbox:

Public WithEvents objInboxItems As Outlook.Items
Private Sub Application_Startup()
  Set objInboxItems = Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub objInboxItems_ItemAdd(ByVal Item As Object)
 MsgBox "New Inbox Item"
End Sub

Custom Folder ("Test") at same level as Inbox:

Public WithEvents objTestItems As Outlook.Items
Private Sub Application_Startup()
  Set objTestItems = Session.GetDefaultFolder(olFolderInbox).Parent.Folders("Test").Items
End Sub
Private Sub objTestItems _ItemAdd(ByVal Item As Object)
 MsgBox "New Test Item"
End Sub

Custom SubFolder underneath Inbox ("SubTest"):

Public WithEvents objSubTestItems As Outlook.Items
Private Sub Application_Startup()
  Set objSubTestItems = Session.GetDefaultFolder(olFolderInbox).Folders("SubTest").Items ' No ".Parent" which means don't go "Up one level"
End Sub
Private Sub objSubTestItems _ItemAdd(ByVal Item As Object)
 MsgBox "New SubTest Item"
End Sub
  • No labels