Sample code for 30+ languages & platforms
Classic ASP Requires Chilkat v11.0.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.

Retrieve a bounce

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

'  Assumes Chilkat is unlocked. See Global Unlock Sample.
success = 0
set http = Server.CreateObject("Chilkat.Http")
http.RequireSslCertVerify = 1
'  Supply your API key from protected configuration; AuthToken adds the Bearer prefix.
http.AuthToken = "SENDGRID_API_KEY"
set resp = Server.CreateObject("Chilkat.HttpResponse")

'  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
        Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>"
    Else
        Response.Write "<pre>" & Server.HTMLEncode( "HTTP " & resp.StatusCode & ": " & resp.BodyStr) & "</pre>"
    End If

    Response.End
End If

If (resp.StatusCode <> 200) Then
    Response.Write "<pre>" & Server.HTMLEncode( "HTTP " & resp.StatusCode & ": " & resp.BodyStr) & "</pre>"
    Response.End
End If

set rows = Server.CreateObject("Chilkat.JsonArray")
success = rows.Load(resp.BodyStr)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Unexpected response: expected JSON.") & "</pre>"
    Response.End
End If

If (rows.Size = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( "No bounce record for this address.") & "</pre>"
    Response.End
End If

set row = Server.CreateObject("Chilkat.JsonObject")
i = 0
Do While (i < rows.Size)
    success = rows.ObjectAt2(i,row)
    Response.Write "<pre>" & Server.HTMLEncode( row.StringOf("email") & ": " & row.StringOf("status") & " " & row.StringOf("reason")) & "</pre>"
    i = i + 1
Loop

%>
</body>
</html>