Execute Method

Microsoft Outlook Visual Basic

Executes the action for the specified item. Returns the Microsoft Outlook item created by the action.

expression.Execute

expression    Required. An expression that returns an Action object.

Remarks

When you run a program that uses the Microsoft Outlook object model to call the Execute method, you receive a warning message. This warning message tells you that a program is trying to execute an action or verb on your behalf and asks if you want to allow that. The warning message contains both a Yes and a No button. However, the Yes button is not available until five seconds have passed since the warning message appeared. You can dismiss the warning message immediately if you click No.

Example

This Visual Basic for Applications (VBA) example uses the Execute method to look through all the actions for the given e-mail message and executes the action called "Reply."

Sub SendReply()
	Dim myOlApp As Outlook.Application
	Dim myNameSpace As Outlook.NameSpace
	Dim MyItem As Outlook.MailItem
	Dim myItem2 As Outlook.MailItem
	Dim myAction As Outlook.Action
	Set myOlApp = CreateObject("Outlook.Application")
	Set myNameSpace = myOlApp.GetNamespace("MAPI")
	On Error GoTo ErrorHandler
	Set MyItem = myOlApp.ActiveInspector.CurrentItem
	For Each myAction In MyItem.Actions
		If myAction.Name = "Reply" Then
			Set myItem2 = myAction.Execute
			myItem2.Send
			Exit For
		End If
	Next myAction
	Exit Sub
	ErrorHandler:
		MsgBox "There is no current item."
End Sub