ItemAdd event not firing every time

J

joebob

I added the code below to fire whenever I receive an item. I then
compiled, closed Outlook, and sent 6 messages to myself from outside
using different addresses. I then opened Outlook and downloaded the 6
messages but MsgBox only fired twice. Is there a mechanism that will
successfully capture every incoming item? This is for O2K SP3 CW mode.
Thanks

Private WithEvents olInboxItems As Items

Private Sub Application_Startup()

Dim objNS As NameSpace

Set objNS = Application.GetNamespace("MAPI")
Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
Set objNS = Nothing

End Sub

Private Sub olInboxItems_ItemAdd(ByVal Item As Object)

If Item.Class = olMail Then
MsgBox ""
End If

End Sub
 
K

Ken Slovak - [MVP - Outlook]

ItemAdd won't fire if too many items come in at once and it won't fire if
you are already within an ItemAdd handler (no reentrancy for interrupt
service routines). Six items shouldn't be too many to fire but a MsgBox is
modal until you close it so you are probably spending too much time in the
ItemAdd handler.

Instead of using MsgBox, replace that line for testing with Debug.Print
Item.Subject

That will run much faster and I predict that you will fire all six times.
 

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