Export (0) Print
Expand All

NewMailEx Event

Office 2003

Occurs when one or more new items are received in the Inbox. This event passes a list of entry IDs of all the items received in the Inbox since the last time the event was fired. This event is not available in Microsoft Visual Basic Scripting Edition (VBScript).

Sub object_NewMailEx(EntryIDs as String)

object    An expression that evaluates to an Application object.

EntryIDs    A string containing entry IDs of all items received in the Inbox since the last time the event was fired. The entry IDs are comma-delimited. The maximum number of entry IDs in the string are limited only by the available memory on the computer.

The NewMailEx event will fire for all item types received in the Inbox such as e-mail messages, meeting requests, and task requests. The behavior will be the same as the NewMail event.

The NewMailEx event will only fire for mailboxes in Microsoft Outlook that provide notification for received message such as Microsoft Exchange Server. Also, the event will fire only if Outlook is running. In other words, it will not fire for the new items that are received in the Inbox when Outlook was not open. Developers who want to access these items for customers running Outlook on an Exchange server e-mail account need to implement their code on the server. However, the NewMailEx event will fire against Cached Exchange Mode in all settings: Download Full Items, Download Headers, and Download Headers and then Full Items.

Example

The following Microsoft Visual Basic for Applications (VBA) example demonstrates how the NewMailEx event returns the entry IDs. To run the example, run the Initialize_Handler routine. The event will fire when one or more messages are received in the Inbox.

    Public WithEvents outApp As Outlook.Application

Sub Intialize_Handler()
    Set outApp = Application
End Sub

Private Sub outApp_NewMailEx(ByVal EntryIDCollection As String)
    Dim mai As Object
    Dim intInitial As Integer
    Dim intFinal As Integer
    Dim strEntryId As String
    Dim intLength As Integer
    
    intInitial = 1
    intLength = Len(EntryIDCollection)
    MsgBox "Collection of EntryIds: " & EntryIDCollection
    intFinal = InStr(intInitial, EntryIDCollection, ",")
    Do While intFinal <> 0
        strEntryId = Strings.Mid(EntryIDCollection, intInitial, (intFinal - intInitial))
        MsgBox "EntryId: " & strEntryId
        Set mai = Application.Session.GetItemFromID(strEntryId)
        MsgBox mai.Subject
        intInitial = intFinal + 1
        intFinal = InStr(intInitial, EntryIDCollection, ",")
    Loop
    strEntryId = Strings.Mid(EntryIDCollection, intInitial, (intLength - intInitial) + 1)
    MsgBox strEntryId
    Set mai = Application.Session.GetItemFromID(strEntryId)
    MsgBox mai.Subject

End Sub
			


Applies to | Application Object


Show:
© 2014 Microsoft