Outlook.Application NewMailExEvent

Jun 14, 2011 at 1:59 PM

Hi everyone,

I'm new to this project, but I really like idea of this and find it very useful.

I'm trying to create a small application that, among others, counts incoming emails. First thing that the app needs to do is to find out when a new message arrives. NewMailEvent works just fine, but it doesn't provide any information on the new mail item. NewMailExEvent is supposed to provide that functionality, but it doesn't work at all. The NewMailExEvent is not called when new mail arrives. I'm using Outlook 2007, is there anything I'm missing here?

Coordinator
Jun 14, 2011 at 2:12 PM

NewMailEx is an event in the Outlook Object Model. The intended consumer for this event is code running in process inside Outlook, such as an Outlook Add-In or a Form Region. This doesn't sound like the context in which you're code is running. The fact that you're looking here means you're considering using MAPI, which is a good choice if your application is unmanaged C++. If it's not, then the OOM or maybe EWS are better options. It would help if I had a better idea what you're trying to accomplish.

Jun 14, 2011 at 2:20 PM
Edited Jun 14, 2011 at 2:30 PM

I don't really want to create Add-In.

What I'm looking for is an email counter, that sits on a machine where it can access the Exchange server, has Outlook installed, the Outlook version varies from 2003 to 2010 and counts all the incoming emails so that the information can be used later for different purposes. I need to know from whom the email was sent, to whom, date and subject. In addition I may want to check to which folder the message was moved to, let's say the check would be done 30 minutes after the message was received. This most probably would be created as system service running in the background, no GUI.

I just started about different approaches that can be used to get that info from Outlook.

Thanks for your help :)

Coordinator
Jun 14, 2011 at 2:38 PM

If you know you're connecting to Exchange, then EWS is an option:

http://msdn.microsoft.com/en-us/library/aa580634(EXCHG.140).aspx

If you're planning on running as a service, then the Outlook Object Model is not an option. You'll need to use either MAPI (advise for notifications, demonstrated in MFCMAPI) or EWS as noted above.