View Single Post
  #2  
Old December 31st 09, 06:55 AM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Outlook 2007 items.count incorrect

Keep in midn that MAPI events are asynchronous and it is possible that
NewMail event is fired before the message is actually created/saved in the
Inbox folder.
Why not use the Items.ItemAdd event on the Inbox folder?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Johnb" wrote in message
...
Outlook 2007, Win 7 64bit. Running code in the newmail event. Works
perfectly on Outlook 2003:

I set my object to the inbox folder:

Set objFolder = objNameSpace.GetDefaultFolder(olFolderInbox)

then here is my test code:

MsgBox objFolder.Items.Count
MsgBox objFolder.Items.Count

The first occurrence of the Msgbox shows "0", the second shows "1" (which
is correct)

Any ideas???

John



Ads