Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Outlook 2007 items.count incorrect (http://www.outlookbanter.com/outlook-vba/98448-outlook-2007-items-count-incorrect.html)

Johnb December 30th 09 07:32 PM

Outlook 2007 items.count incorrect
 
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


Dmitry Streblechenko December 31st 09 06:55 AM

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




Johnb January 2nd 10 07:58 PM

Outlook 2007 items.count incorrect
 
It has worked fine in 2003 for several years. In the end I rewrote it and
triggered it from a rule.

Thanks for your suggestion


John
"Dmitry Streblechenko" wrote in message
...
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





All times are GMT +1. The time now is 02:25 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com