使用NeverBounce验证电子邮件

时间:2019-01-05 08:36:45

标签: vb.net

我正在使用此代码段验证我的NeverBounce帐户:

Private Sub btnGo_Click(sender As Object, e As RoutedEventArgs) Handles btnGo.Click

    Dim nb As NeverBounceSdk = New NeverBounceSdk("secret_.......")
    Dim rsp As AccountInfoResponseModel = nb.Account.Info().Result
    txtRes.Text = rsp.ToString
End Sub

但是我没有得到回应。根据NeverBounce文档,这似乎是正确的方法。你知道为什么这行不通吗?

1 个答案:

答案 0 :(得分:0)

必须使用异步方法。请参阅以下内容。

Public Async Function IsValidAsync() As Task(Of Boolean)
    Dim val As SingleResponseModel = Await ValidateAddressAsync()
    Return If(val.result = "valid", True, False)
End Function
Private Async Function ValidateAddressAsync() As Task(Of SingleResponseModel)
    Dim nb As NeverBounceSdk = New NeverBounceSdk("NeverBounce key")
    Dim mdl As New SingleRequestModel With {.email = FullAddress, .timeout = 30}
    Return Await nb.Single.Check(mdl)
End Function