Write Event

Microsoft Outlook Visual Basic

Show All

Write Event

       

Occurs when a Microsoft Outlook item is saved, either explicitly (for example, using the Save or SaveAs methods) or implicitly (for example, in response to a prompt when closing the item's inspector).

Sub object_Write(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 Boolean (not used in VBScript). False when the event occurs. If the event procedure sets this argument to True, the save operation is not completed.

Remarks

In VBScript, if you set the return value of this function to False, the save operation is not completed.

Example

This VBScript example uses the Write event and warns the user that the item is about to be saved and will overwrite any existing item and, depending on the user's response, either allows the operation to continue or stops it.

Function Item_Write()
    myMsg = "The item is about to be saved. Do you wish to overwrite the existing item?"
    myResult = MsgBox(myMsg, 289, "Save")
    If myResult = 1 Then
        Item_Write = True
    Else
        Item_Write = False
    End If
End Function