Sifu
Sifu

Reputation: 1082

NewMailEx not firing in Outlook2007

I am trying to code a script that catches the Emails Outlook receives to then process them. But it isn't working so far.

I tried to use a premade code snippet(Sorry French) to start from, but it's not working.. What do I need to do to make it fire when an Email is received?

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
'---------------------------------------------------------------------------------------
' Procédure : Application_NewMailEx
' Auteur    : Dolphy35
' Site      : http://dolphy35.developpez.com
'---------------------------------------------------------------------------------------
'
Dim MyApp As Outlook.Application
Dim MyMail As Object
Dim MyNameSpace As Outlook.NameSpace
Dim MyFolder As Outlook.Folder

Set MyApp = Outlook.Application
Set MyNameSpace = MyApp.GetNamespace("MAPI")
Set MyDossier = MyNameSpace.GetDefaultFolder(olFolderInbox)
Set MyMail = Application.Session.GetItemFromID(EntryIDCollection)

    If MyMail.SenderEmailAddress = "[email protected]" Then
        MyMail.Move MyFolder.Folders("Temp")
    End If

End Sub

I am using OutLook 2007 and I placed this code in Module1.

Upvotes: 1

Views: 372

Answers (1)

David Zemens
David Zemens

Reputation: 53663

The NewMailEx event handler should go in the code module for ThisOutlookSession, for example:

enter image description here

Upvotes: 3

Related Questions