Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VBA - run code when certain email is received

Posted on 2010-09-16
5
Medium Priority
?
331 Views
Last Modified: 2012-05-10
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.....
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 33693959
Hi, murbro.

Create an Outlook script that calls the Excel script.  Once done, create a rule that fires for these messages.  Set the rule's action to "run a script" and select teh Outlook script as the one to run.
0
 

Author Comment

by:Murray Brown
ID: 33694346
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
0
 

Author Closing Comment

by:Murray Brown
ID: 33696278
thanks
0
 
LVL 76

Expert Comment

by:David Lee
ID: 33696356
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.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 33696364
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.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question