outlook 2010 mail item count doesnt match display

Status
Not open for further replies.

Terri Jones

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server
Re: work email account outlook 2010/exchange server. Using excel macro I capture all outlook messages into a spreadsheet. I receive upwards of a thousand emails daily. Using a for next loop I move through the mail item count and record them in excel. The mail item count is half of the displayed total. If I have 250 messages the mail item count will return 125 causing me to run the process multiple times to clear inbox. the next round picks up 62, then 31, then 16,8,4,2,1 etc.. (This is not a priority with our IT dept. I am on my own and trying to workaround issue).

I want to retest item count within the current macro to keep working to get to an empty inbox. Current mail item counts are not correct, do not match the displayed totals. I am thinking about having macro make multiple attempts to loop through a testing sequence that set outlook/run macro that records messages/clear instance/reset outlook instances until the inbox mail item count returns 0 before exiting macro process. Does this seem plausible? Any suggestions? Is there another collection where I could obtain a more reliable count?
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Do you remove the items in your loop? If so, loop backwards. While Count correctly returns the remaining items, it's the index that points to non-existing items.
 

Terri Jones

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server
Hi Michael,
Sorry for the delay. Thought I had asked for email notifications.


Yes I am removing the items as I loop through them.
Here's where I am capturing count

For iRow = 1 To Folder.Items.Count
'not exactly sure what reversing the loop looks
To reverse would that be
For iRow = -1 to Folder.Items.Count
or
For iRow = Folder.Items.Count to -1

Thanks
T
 

Terri Jones

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server
Thanks Michael for putting me on the right track. This code works
imailcount = Folder.Items.Count
For iRow = imailcount To 1 Step -1
Set Msg = Folder.Items(iRow)

thanks again
 
Status
Not open for further replies.
Top