VBScript Requires Chilkat v11.0.0+
VBScript
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 VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 0
' Assumes Chilkat is unlocked. See Global Unlock Sample.
set email = CreateObject("Chilkat.Email")
email.From = "Workshop team <events@example.com>"
success = email.AddTo("Alex Rivera","alex@example.net")
If (success <> 1) Then
outFile.WriteLine(email.LastErrorText)
WScript.Quit
End If
email.Subject = "Workshop registration"
email.Body = "Your workshop registration is confirmed."
set request = CreateObject("Chilkat.JsonObject")
success = request.UpdateString("email",email.GetMime())
success = request.UpdateString("options","short")
set http = CreateObject("Chilkat.Http")
http.RequireSslCertVerify = 1
set resp = CreateObject("Chilkat.HttpResponse")
success = http.HttpJson("POST","https://spamcheck.postmarkapp.com/filter",request,"application/json",resp)
If ((success <> 1) Or (resp.StatusCode <> 200)) Then
outFile.WriteLine("SpamCheck request failed. HTTP " & resp.StatusCode)
WScript.Quit
End If
set result = CreateObject("Chilkat.JsonObject")
success = result.Load(resp.BodyStr)
If (success <> 1) Then
outFile.WriteLine(result.LastErrorText)
WScript.Quit
End If
If (result.BoolOf("success") <> 1) Then
outFile.WriteLine(result.StringOf("message"))
WScript.Quit
End If
outFile.WriteLine("SpamAssassin score: " & result.StringOf("score"))
outFile.Close