So, I am currently working on a script that takes emails and processes them in a certain way. I want it to work fully automatically without any human interaction, for the most part I have done this.
The issue I am having is if the mailbox receives an email whilst outlook is closed, I can not make the program kick off because of that email. If I use the
Private Sub Application_Startup() 'Runs at application start
Call ProcessCode
End Sub
Then it runs too early and the message hasn't been received yet so can't be processed.
I have tried
Private Sub Application_NewMail() 'Runs whenever a new mail item is recieved
Call ProcessCode
End Sub
But for some reason this doesn't run in this scenario (runs when mail is received normally)
I have also tried Application_ItemLoad
, and Application_MAPILogonComplete
but neither of these seemed to work.
What I ideally want is to run the code whenever a unread mail item is present in the mail box, regardless of how it got there.
Thanks in advance
Alex Spicer