Send Event

Microsoft Outlook Visual Basic

Occurs when the user selects the Send action for a Microsoft Outlook item.

Sub object_Send(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 send operation is not completed and the inspector is left open.

Remarks

In Microsoft Visual Basic Scripting Edition (VBScript), if you set the return value of this function to False, the item is not sent.

Example

This Visual Basic for Applications (VBA) example uses the Send event and sends an item with an automatic expiration date. The sample code must be placed in a class module such as ThisOutlookSession, and the SendMyMail procedure must be called before the event procedure can be called by Microsoft Outlook.

Public WithEvents myItem As Outlook.MailItem
  
Sub SendMyMail()
	Set myItem = Outlook.CreateItem(olMailItem)
	myItem.To = "Dan Wilson"
	myItem.Subject = "Data files information"
	myItem.Send
End Sub

Private Sub myItem_Send(Cancel As Boolean)
	myItem.ExpiryTime = #2/2/2003 4:00:00 PM#
End Sub