Open Event

Microsoft Outlook Visual Basic

Show All

Open Event

       

Occurs when a Microsoft Outlook item is being opened in an Inspector. When this event occurs, the Inspector object is initialized but not yet displayed. The Open event differs from the Read event in that Read occurs whenever the user selects the item in a view that supports in-cell editing as well as when the item is being opened in an Inspector.

Sub object_Open(Cancel As Boolean)

object   An expression that evaluates to one of the objects in the Applies To list. In VBScript, use the word Item.

Cancel   Optional (not used in VBScript). False when the event occurs. If the event procedure sets this argument to True, the open operation is not completed and the inspector is not displayed.

Remarks

In VBScript, if you set the return value of this function to False, the open operation is not completed and the inspector is not displayed.

Example

This VBScript example uses the Open event to display the "All Fields" page every time the item is opened.

Function Item_Open()
    Item.GetInspector.SetCurrentFormPage "All Fields"
End Function

This VBScript example uses the Unread property to detect whether the item has been previously read. If it has, then it asks if the user wants to open it. If the user answers No, the return value is set to False to prevent the item from opening.

Function Item_Open()
    If Item.UnRead = False Then
        myMsg = "Do you want to open this message again?"
        If MsgBox(myMsg, 4) = 6 Then
            Item_Open = True
        Else
            Item_Open = False
        End If
    End If
End Function