Solved

Outlook COM Add-in: Application_NewMailEx  not getting fired

Posted on 2009-04-01
3
892 Views
Last Modified: 2012-05-06
I noticed that Application_NewMailEx is not getting called on new mail arrieved. Do I need to set any object for this event as well as we did it in objMailItem_Send in http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/Q_24253844.html?

Thanks.
0
Comment
Question by:deshaw
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 250 total points
ID: 24037871
Hi, deshaw.

Yes, objects ALWAYS have to be initialized before they can process events.  Application_NewMailEx will work fine in Outlook without you doing anything because Application refers to an intrinsic object in Outlook.  But, add-ins don't have the application object by default.  Your add-in code has to create an instance and initialize it.  Since you are using that add-in template, I believe it has done the work for you.  Does it contain a line something like

    Dim WithEvents objApp As Outlook.Application

If so, then to trap the NewMailEx event you simply need to modify your code to read

    Sub objApp_NewMailEx

instead of
    Sub Application_NewMailEx

In this case objApp is your add-in's instance of the application object.  Does that make sense?
0
 
LVL 1

Author Closing Comment

by:deshaw
ID: 31565249
thanks. that works perfectly.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24038110
You're welcome.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

Find out how to use dynamic social media in email signatures with this top 10 DOs & DON’Ts.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now