0
votes

I am having trouble detecting an in-firm (EX type) invalid email address of an outlook recipient using the following code:

The invalid email address has a typographical error say, [email protected] for [email protected].

How do I detect an in-firm recipient having an invalid email address?

Dim Email as Outlook.Mailitem
Dim Recipients As Outlook.Recipients
Set Recipients = Email.Recipients
    Recipients.Resolveall

If Not Recipients.ResolveAll Then
    For i = Recipients.Count To 1 Step -1
        If Not Recipients(i).Resolved Then
            MsgBox Recipients(i).Name
        End If
    Next i
End if
1

1 Answers

0
votes

Have you checked the following code:

    Public Function ResolveDisplayNameToSMTP(sFromName, OLApp As Object) As String

    Dim oRecip As Object  'Outlook.Recipient

    Set oRecip = OLApp.Session.CreateRecipient(sFromName)
    oRecip.Resolve
    oRecipName = oRecip.Name

    If oRecip.Resolved And InStr(oRecipName, "@") = 0 Then
        ResolveDisplayNameToSMTP = "Valid"
    Else
        ResolveDisplayNameToSMTP = "Not Valid"
    End If

End Function

For more, please see this: VBA CODE to Verify Email Address Found in Outlook Global Address List