Visual Basic 6.0 Requires Chilkat v11.0.0+
Visual Basic 6.0
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 Visual Basic 6.0 Downloads
Dim success As Long
success = 0
' Assumes Chilkat is unlocked. See Global Unlock Sample.
success = 0
Dim http As New ChilkatHttp
http.RequireSslCertVerify = 1
' Supply your API key from protected configuration; AuthToken adds the Bearer prefix.
http.AuthToken = "SENDGRID_API_KEY"
Dim resp As New ChilkatHttpResponse
' SetUrlVar encodes the raw address as a URL component, including the plus sign.
success = http.SetUrlVar("address","avery+orders@example.com")
success = http.HttpNoBody("GET","https://api.sendgrid.com/v3/suppression/bounces/{$address}",resp)
If (success <> 1) Then
If (resp.StatusCode = 0) Then
Debug.Print http.LastErrorText
Else
Debug.Print "HTTP " & resp.StatusCode & ": " & resp.BodyStr
End If
Exit Sub
End If
If (resp.StatusCode <> 200) Then
Debug.Print "HTTP " & resp.StatusCode & ": " & resp.BodyStr
Exit Sub
End If
Dim rows As New ChilkatJsonArray
success = rows.Load(resp.BodyStr)
If (success <> 1) Then
Debug.Print "Unexpected response: expected JSON."
Exit Sub
End If
If (rows.Size = 0) Then
Debug.Print "No bounce record for this address."
Exit Sub
End If
Dim row As New ChilkatJsonObject
Dim i As Long
i = 0
Do While (i < rows.Size)
success = rows.ObjectAt2(i,row)
Debug.Print row.StringOf("email") & ": " & row.StringOf("status") & " " & row.StringOf("reason")
i = i + 1
Loop