The problem is with automating the job not with the code itself. If I run the job manually it is able to read the mail with no problems. If I run the job manually with a continuous scan there's no problem. However, if I schedule the job or run the code as a service it fails for the reasons described in the article.
I was hoping for another method like Win32::Mapi, but I'm not even sure if that works with Public Folders and I'm having trouble getting the module.