Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VBA - run code when certain email is received

Hi

I want to run VBA code in Excel when an email with a certain header is used. What is the best way to do this? Should I set up a timer that checks the inboc every few minutes? I am using Office 2010. Maybe I should set up a rule in Outlook.....
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

Hi
Thanks. I just looked at an article that compared three options
http://www.outlookcode.com/article.aspx?id=62
would the third option in this article not be the best solution, i.e. the NewMailEx event
thanks
If you expect to get a lot of these messages, then yes.  It also requires more coding.  The code has to check the messages to get the ones you want.  The rule approach doesn't require coding that.  Option 3 is also less efficient in that it must check every message.  The rule does too, but that's native code which should be much faster at it.  Rules only fire for messages, while option 3 will fire for everything you receive (receipts, meeting requests, etc.).  That's the downside.  The upside is that the core code (i.e. the code that calls the Excel macro) is more efficient.  Outlook can create the Excel objects once for a group of messages rather than once for each message as it would with the rule based approach.  As that article points out the approach is based on how many of these messages you receive and the frequency.
By the way, I'll be glad to help with the code.  I just need to know how to identify the messages and the name of the Excel macro to run.