Here is a thought - your olItem
is defined as a mailItem
. It is possible that the code fails when your next item in the mailbox is not a mail item? Would a calendar request or something else cause this? You might want to put a Debug.Print statement in the inner loop to see what objects are being looked at - and see if the loop does in fact execute until it comes across a strange item in your inbox...
As a quick fix, if you allowed it to be a variant, you would not get a type error. So you would just declare it as
Dim olItem
without the as mailItem
It's a long shot.