Originally Posted by Scorpions4ever
You know what? It could be that moving messages out of a folder, while you're still looping through the folder, could cause the loop to terminate early. I used to have the same problem when enumerating files in a directory and deleting files while still looping through the file list. This was not a problem with the language, but a problem of the underlying OS.
The way to handle it is via two loops:
1. Loop through the list of messages/files and look for items to move/delete
2. For each item that needs to be moved or deleted, push that item in a separate array.
3. Repeat step 1 until you have no more items.
4. Now that you have the array built, then go through the array and delete/move every element in the array,
You are absolutely right. That's what I had done earlier but instead of moving them to another folder I just deleted them. Thanks nonetheless.