AutoIt Requires Chilkat v11.0.0+
AutoIt
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 AutoIt Downloads
Local $bSuccess = False
; Assumes Chilkat is unlocked. See Global Unlock Sample.
$oEmail = ObjCreate("Chilkat.Email")
$oEmail.From = "Workshop team <events@example.com>"
$bSuccess = $oEmail.AddTo("Alex Rivera","alex@example.net")
If ($bSuccess <> True) Then
ConsoleWrite($oEmail.LastErrorText & @CRLF)
Exit
EndIf
$oEmail.Subject = "Workshop registration"
$oEmail.Body = "Your workshop registration is confirmed."
$oRequest = ObjCreate("Chilkat.JsonObject")
$oRequest.UpdateString("email",$oEmail.GetMime())
$oRequest.UpdateString("options","short")
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.RequireSslCertVerify = True
$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpJson("POST","https://spamcheck.postmarkapp.com/filter",$oRequest,"application/json",$oResp)
If (($bSuccess <> True) Or ($oResp.StatusCode <> 200)) Then
ConsoleWrite("SpamCheck request failed. HTTP " & $oResp.StatusCode & @CRLF)
Exit
EndIf
$oResult = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oResult.Load($oResp.BodyStr)
If ($bSuccess <> True) Then
ConsoleWrite($oResult.LastErrorText & @CRLF)
Exit
EndIf
If ($oResult.BoolOf("success") <> True) Then
ConsoleWrite($oResult.StringOf("message") & @CRLF)
Exit
EndIf
ConsoleWrite("SpamAssassin score: " & $oResult.StringOf("score") & @CRLF)