• Subject: Re: looping through inbox messages / debugger under Outlook VBA
  • Author: Sue Mosher [MVP-Outlook]
  • Date: 10 Apr 2008
  • References: 1 2 3
I would use the NewMailEx event, which is the most reliable of all those available for processing new messages; see http://www.outlookcode.com/article.aspx?id=62 . I've seen it skip items only when running under extremely heavy load on a POP3 account. Check each new item to see if it meets your criteria. If so, process it. If, after a while, you find that some log messages are being skipped, you can add code to the NewMailEx event handler to check to see if any older items are unprocessed. Use the MAPIFolder.Items.Find or Restrict method to do a search. Or, supplement NewMailEx with a Windows API timer routine that fires off every few minutes to check for new items.
Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54
"Mark VII" <MarkVII@discussions.microsoft.com> wrote in message news:7B011ADE-E543-416F-935C-53FD8CDD3A9E@microsoft.com...
> Hi Sue -- > > Points well taken. What I did is driven partly by our processing > requirments, and partly due to my inexperience with programming Outlook. (I > can make Access and Excel sing and dance, but this is my first attempt at > automated processing of incoming email.) Here's a capsule on our situation > and my thought process, and am open wide to feedback. I've got a question > for you at the end. > > We have some software that creates very large log files as it runs, but no > built in tools to analyze the logs. We have an Access database that parses > the log files, and loads some tables so we can query this data. Currently, > we save these log files by hand. Because our software sends out an automated > email with the log file text in the body, I want to automatically save the > body of these emails as a plain text file and move the emails to a desingated > folder. > > Based on the research I've done so far, if a lot of emails arrive in a short > period of time, a rule that triggers a script may not always fire. > Similarly, I've read that the ItemAdd event and the NewMail events don't > always fire. Consequently, I thought it prudent to walk the whole inbox, so > we don't miss any files. > > This leads to a question about your suggestion -- if I create a standard VBA > program, what is the best way to trigger it when a new email shows up? > Should I just write the program to run in a loop, looking for emails that > meet its selection criteria? (These log files come from a specific email > address and have specific text in the subject line.) This needs to run on a > user's PC (particulary mine), so what I do can't tie up the machine. > > Thanks a million, > Mark > >
09 Apr 2008looping through inbox messages / debugger under Outlook VBA.Mark VII
09 Apr 2008|- Re: looping through inbox messages / debugger under Outlook VBA.Ken Slovak - [MVP - O...
09 Apr 2008|  \ Re: looping through inbox messages / debugger under Outlook VBA.Mark VII
10 Apr 2008|     \ Re: looping through inbox messages / debugger under Outlook VBA.Ken Slovak - [MVP - O...
09 Apr 2008\ Re: looping through inbox messages / debugger under Outlook VBA.Sue Mosher [MVP-Outlook]
10 Apr 2008   \ Re: looping through inbox messages / debugger under Outlook VBA.Mark VII
10 Apr 2008      \ Re: looping through inbox messages / debugger under Outlook VBA.Sue Mosher [MVP-Outlook]
10 Apr 2008         \ Re: looping through inbox messages / debugger under Outlook VBA.Mark VII
All times are in (US) Eastern Daylight Time (GMT -4:00)