NewMailEx Only provides First e-mail in inbox

B

ben

When using NewMailEx to get a list of received e-mails, EntryIDCollection
will only return the very first e-mail received, even if 10-15 e-mails come
in at the same time.

This is my code in it's entirety.


Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim arr() As String
Dim i As Integer
Dim m As MailItem
On Error Resume Next
arr = Split(EntryIDCollection, ",")
For i = 0 To UBound(arr)
Set m = Application.Session.GetItemFromID(arr(i))
MsgBox m.Subject
Next
End Sub


Or am I going at this backwards, does (Will return a list of all e-mails
that have arrived since this event last fired) mean that if I receive 5
e-mails, the first one will trigger.. but the next time I receive an e-mail
the previous 4 , plus the one just in will trigger? And if so, won't that
leave a few e-mails always in limbo?
 
S

Sue Mosher [MVP]

Don't use a MsgBox to test any kind of automatic processing, because it's
modal and will stop execution while the box is displayed. Use Debug.Print
instead.

If you're working with an Exchange account in cached mode, NewMailEx will
fire for every single item received, so you'll see only one entry ID each
time. In online mode, it will return multiple items, but may skip a small
number under extremely heavy loads.
 
B

ben

Sue,

Thank you, that was precisely the problem. Changed my code to mark all
incoming messages as read for testing, and worked like a charm. I was a
little lost because all the examples I found used MsgBox for testing.
 

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