Sample code for 30+ languages & platforms
B4X Requires Chilkat v11.0.0+

Request a SpamAssassin score for a sample email

See more Email Object Examples

Submit a synthetic message to Postmark’s SpamCheck endpoint. The service receives the complete MIME you provide. Request a short result and check both the HTTP status and the API success field before reading the numeric score. SpamCheck API documentation.

Chilkat B4X Downloads

B4X
Dim success As Boolean = False

'  Assumes Chilkat is unlocked. See Global Unlock Sample.

Dim email As ChilkatEmail
email.Initialize
email.From = "Workshop team <events@example.com>"
success = email.AddTo("Alex Rivera", "alex@example.net")
If success <> True Then
    Log(email.LastErrorText)
    Return
End If

email.Subject = "Workshop registration"
email.Body = "Your workshop registration is confirmed."
Dim request As ChilkatJsonObject
request.Initialize
request.UpdateString("email", email.GetMime)
request.UpdateString("options", "short")
Dim http As ChilkatHttp
http.Initialize("http")
http.RequireSslCertVerify = True
Dim resp As ChilkatHttpResponse
resp.Initialize
success = http.HttpJson("POST", "https://spamcheck.postmarkapp.com/filter", request, "application/json", resp)
If (success <> True) Or (resp.StatusCode <> 200) Then
    Log("SpamCheck request failed. HTTP " & resp.StatusCode)
    Return
End If

Dim result As ChilkatJsonObject
result.Initialize
success = result.Load(resp.BodyStr)
If success <> True Then
    Log(result.LastErrorText)
    Return
End If

If result.BoolOf("success") <> True Then
    Log(result.StringOf("message"))
    Return
End If

Log("SpamAssassin score: " & result.StringOf("score"))