A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Outlook 2007 items.count incorrect



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 30th 09, 07:32 PM posted to microsoft.public.outlook.program_vba
Johnb
external usenet poster
 
Posts: 4
Default 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

Ads
  #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



  #3  
Old January 2nd 10, 07:58 PM posted to microsoft.public.outlook.program_vba
Johnb
external usenet poster
 
Posts: 4
Default 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



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unread messages count incorrect on login screen molim Outlook Express 3 August 2nd 07 01:22 AM
Explanation of Items count? salad Outlook and VBA 2 April 4th 07 06:14 PM
error retrieving folder.items.count kappe79 Outlook and VBA 3 September 19th 06 01:29 PM
Unread count incorrect + no spell checking StainlessSteelRat Outlook Express 6 February 26th 06 01:32 PM
count items in an Outlook View norm Outlook - Using Contacts 3 February 6th 06 04:02 AM


All times are GMT +1. The time now is 01:55 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.