Code that fires everytime an email arrives...

  • Thread starter Thread starter J S
  • Start date Start date
J

J S

I have some vba code in the ThisOutlookSession Module that causes some code
to run whenever an email arrives in the inbox.

Normally, this works fine except when I open up the VBA enviroment and do
some editing. Then the olInboxItems_ItemAdd event stop firing until I
restart outlook. Does anybody know why this is occuring and if I can stop
this behavior?

-J

Private WithEvents olInboxItems As Items
------------------------------------------------------------------
Private Sub Application_Startup()

Dim objNS As NameSpace
Set objNS = Application.GetNamespace("MAPI")
' instantiate objects declared WithEvents
Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
Set objNS = Nothing
End Sub
 
Back
Top