VB.NET Requires Chilkat v11.0.0+
VB.NET
SendGrid: Look up a bounced email address
See more SendGrid Examples
Look up a recipient on the bounce suppression list without changing it. SendGrid returns an array. An empty array means there is no bounce record for this lookup; it does not prove a particular message reached the inbox.
Chilkat VB.NET Downloads
Dim success As Boolean = False
' Assumes Chilkat is unlocked. See Global Unlock Sample.
success = False
Dim http As New Chilkat.Http
http.RequireSslCertVerify = True
' Supply your API key from protected configuration; AuthToken adds the Bearer prefix.
http.AuthToken = "SENDGRID_API_KEY"
Dim resp As New Chilkat.HttpResponse
' SetUrlVar encodes the raw address as a URL component, including the plus sign.
http.SetUrlVar("address","avery+orders@example.com")
success = http.HttpNoBody("GET","https://api.sendgrid.com/v3/suppression/bounces/{$address}",resp)
If (success <> True) Then
If (resp.StatusCode = 0) Then
Debug.WriteLine(http.LastErrorText)
Else
Debug.WriteLine("HTTP " & resp.StatusCode & ": " & resp.BodyStr)
End If
Exit Sub
End If
If (resp.StatusCode <> 200) Then
Debug.WriteLine("HTTP " & resp.StatusCode & ": " & resp.BodyStr)
Exit Sub
End If
Dim rows As New Chilkat.JsonArray
success = rows.Load(resp.BodyStr)
If (success <> True) Then
Debug.WriteLine("Unexpected response: expected JSON.")
Exit Sub
End If
If (rows.Size = 0) Then
Debug.WriteLine("No bounce record for this address.")
Exit Sub
End If
Dim row As New Chilkat.JsonObject
Dim i As Integer = 0
While (i < rows.Size)
rows.ObjectAt2(i,row)
Debug.WriteLine(row.StringOf("email") & ": " & row.StringOf("status") & " " & row.StringOf("reason"))
i = i + 1
End While