BeforeCheckNames Event

Occurs just before Microsoft Outlook starts resolving names in the recipient collection for an e-mail item.

Subobject**_BeforeCheckNames(Cancel As Boolean)**

*object   * An expression that evaluates to an object in the Applies To list. In Microsoft Visual Basic Scripting Edition (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 operation is cancelled and the names in the recipients collection are not resolved.


You use the BeforeCheckNames event in VBScript, but the event does not fire when an e-mail name is resolved on the form.

The event does not fire under the following circumstances:

  • You customized a Journal Entry form and then resolved a contact in the Contacts field.
  • You customized a Contact form and then resolved a contact in the Contacts field.
  • You customized any type of form and Outlook automatically resolved the name in the background.
  • You programmatically created and resolved a recipient.


This Visual Basic for Applications (VBA) example asks the user if the user wants to resolve names and returns False to cancel the operation if the user answers no. The sample code must be placed in a class module such as ThisOutlookSession, and the SendMail() procedure should be called before the event procedure can be called by Outlook.

Public WithEvents myItem As Outlook.MailItem
Public olApp As New Outlook.Application

Private Sub myItem_BeforeCheckNames(Cancel As Boolean)
    If MsgBox("Do you want to resolve names now?", 4) = vbOK Then
        Cancel = True
    End If
End Sub

Public Sub SendMail()
    Set olApp = CreateObject("Outlook.Application")
    Set myItem = olApp.CreateItem(olMailItem)
    myItem.Recipients.Add ("Dan Wilson")
    myItem.Recipients.Add ("Nate Sun")
    myItem.Body = "Good morning!"
End Sub

Applies to | AppointmentItem Object | ContactItem Object | DistListItem Object | DocumentItem Object | JournalItem Object | MailItem Object | MeetingItem Object | PostItem Object | RemoteItem Object | ReportItem Object | TaskItem Object | TaskRequestAcceptItem Object | TaskRequestDeclineItem Object | TaskRequestItem Object | TaskRequestUpdateItem Object

See Also | Using events with Automation