Execute Method

Microsoft Outlook Visual Basic

Show All

Execute Method

       

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.

Example

This Visual Basic for Applications example uses the Execute method to look through all the actions for the given mail message, and executes the action called "Reply to All."

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
On Error GoTo ErrorHandler
Set myItem = myOlApp.ActiveInspector.CurrentItem
For Each a In myItem.Actions
    If a.Name = "Reply to All" Then
        Set myItem2 = a.Execute
        Exit For
    End If
Next a
Exit Sub
ErrorHandler:
    MsgBox "There is no current item!"