Code that fires everytime an email arrives...

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top