?
Solved

Parculiar loop behaviour

Posted on 2003-03-23
3
Medium Priority
?
240 Views
Last Modified: 2010-04-07
Following on from my last question about referencing Inbox sub-folders, I have noticed that the VB loop that contains the code that deals with the Inbox emails and the subfolders is not dealing with all the emails in the Inbox. The loop is exited once 50% of the Inbox emails have been processed, rounded up. The code loop is as follows:

    For Each oMsg In oFolder.Items ' Emails in Inbox
       ' many lines of email action code
    Next ' messages

The code within the for/next loop does not jump to other routines except to write to a log file, and there are no early exit statements. oMsg is declared as an Object and oFolder is declared as a Variant. The Outlook linkage is as follows:
    Set oApp = CreateObject("Outlook.Application")
    Set oNS = oApp.GetNamespace("MAPI")
   
    'Set folder to check the INBOX
    Set oFolder = oNS.GetDefaultFolder(olFolderInbox)

Any ideas why the loop should be exited at 50% of Inbox messages processed?

   
0
Comment
Question by:vbmds
2 Comments
 
LVL 13

Accepted Solution

by:
stefri earned 150 total points
ID: 8216252
did you try to assign oFolder.Items to a temp variable ?
set inItems = oFolder.Items

for each oMsg in inItems

next

or you could try:

itCount = oFolder.Items.count

for i = itCount to 1 step -1

next

oFolder could be declared as MapiFolder
0
 

Author Comment

by:vbmds
ID: 10489404
Sorry, must have overlooked the response notification about stefri's response. I have endup using the forced loop method to control the function.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
A few solutions to a problem some of us have been having when trying to add Hostgator email accounts to Outlook 2016 (will probably work with Outlook 2013 as well).
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question