Code that fires whenever 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
 
K

Ken Slovak - [MVP - Outlook]

That is expected behavior if you are editing the VBA project code.
After you are done just place the cursor in the Application_Startup
event handler and press F5 to execute it again and your ItemAdd
handler should start working again.
 

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