AttachmentAdd Event

Microsoft Outlook Visual Basic

AttachmentAdd Event

       

Occurs when an attachment has been added to an item.

Sub object_AttachmentAdd(Attachment As Attachment)

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

Attachment   Required. The Attachment that was added to the item.

Example

This VBScript example checks the size of the item after an embedded attachment has been added and displays a warning if the size exceeds 500,000 bytes.

Sub Item_AttachmentAdd(ByVal NewAttachment)
    If NewAttachment.Type = 1 Then
        Item.Save
        If Item.Size > 500000 Then
            MsgBox "Warning: Item size is now " & Item.Size & " bytes."
        End If
    End If
End Sub