Hi,
I'm new to Outlook VBA, but I've done some in Word and extensive Excel macros, as well as .NET development. We are running Outlook 2010.
I get a number of validation emails (success/fail) from overnight jobs. Rather than reading each one every morning, I got the idea to build a macro to consolidate all the results into one email. This works well for the most part, but I have a couple of issues.
1) The macro does not always automatically run each morning when I start Outlook. I have added a Private Sub Application_Startup routine in the 'This Outlook Session' folder, which calls my routine. When I launch Outlook, it works some days and other days it does not.
2) When it does run, I've had an issue with it running before the Inbox is refreshed. So often, when my macro does run, many of my jobs show a status of 'Unknown' (from my code), because it can't find many of the emails. As soon as my macro runs, Outlook refreshes the inbox and the missing emails are loaded in. I tried putting a delay at the start of my macro, like the code at the bottom of this post, but this just seems to hold up all the Outlook processes for a minute, then my code runs and then the inbox is refreshed. I've tried to find VBA code that refreshes the inbox, but I haven't found any.
Can anyone tell me why my macro only runs occasionally, and how to refresh my inbox using VBA?
Thanks for your help!
fCurrentTime = Now
Do Until fCurrentTime + TimeValue("00:01:00") <= Now
DoEvents
Loop