I have a script that almost works…when I run this the following happens…
If 4 emails present, it will move 2. If 2 emails present, it will move 1, and if 1 email present, then it will move the 1. So for 4 emails, the process needs run 3 times to clear the inbox down
I understand a loop etc starts at 0 but I’m not using an array, I’m merely using:
$Inbox.Items | ForEach-Object -Process { $_.Move($MoveTarget) }
Can anybody advise me why the email process in these numbers (4emails = 2moved, 2emails = 1moved) at least if I knew why then I might be able to resolve myself. I guess it’s something to do with the fact that I am moving emails that constitute a stack?
I have a solution whereby I repeat the above loop processing the emails within an outer loop i.e. a loop within a loop, until all emails have been processed but to me it’s inefficient so would like to resolve it.