检测到来自Outlook收件人的无效的公司内部电子邮件地址

时间:2018-12-13 04:57:10

标签: vba outlook detect

我无法使用以下代码检测Outlook收件人的公司内(EX类型)无效的电子邮件地址:

无效的电子邮件地址有一个印刷错误,例如test@mail.com的tes@mail.com。

如何检测公司内部收件人的电子邮件地址无效?

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 个答案:

答案 0 :(得分:0)

您是否检查了以下代码:

    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

有关更多信息,请参见:VBA CODE to Verify Email Address Found in Outlook Global Address List