New Email Notification in Outlook

celobateira

Member
Joined
Feb 19, 2007
Messages
18
Programming Experience
Beginner
Hi everyone,

I'm still struggling in Outlook 'add-ins' and now my quest is to execute some

methods everytime a new mail arrives.

I'm working in VB 2005.

I've been looking for the standard methods like:

OnConnection, OnDisconnection, OnStartupComplete

but How do I get the event for a new email?

Thanx
 
NewMail event of Outlooks Application object. I have not worked with Add-ins but it will probably be something like this:
VB.NET:
Private Sub outlookApp_NewMail() Handles outlookApp.NewMail
'check mails in inbox
End Sub
You have to check each mail in inbox and see if its UnRead property is True.

The Outlooks Application object I declared like this:
VB.NET:
WithEvents outlookApp As Outlook.Application
As I understand it, with addins you get the reference to this object through the OnConnection methods 'application' parameter and assign local variable.
 
thanx JohnH, I solved my problem with this:

VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]WithEvents[/COLOR][/SIZE][SIZE=2] colItems [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Outlook.Items[/SIZE]

and the event:
VB.NET:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] colItems_ItemAdd([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] Item [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] colItems.ItemAdd[/SIZE]
 
...and you referenced colItems with inbox Items collection?
 
Back
Top