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

Get SpamAssassin Score for an Email

See more Email Object Examples

Uses Postmark’s spam API (a RESTfull interface to the SpamAssassin filter tool) to analyze an email to get a spam score.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

;  This example requires the Chilkat API to have been previously unlocked.
;  See Global Unlock Sample for sample code.

;  First build an email to check.
$oEmail = ObjCreate("Chilkat.Email")
$oEmail.Subject = "this is a test"
$oEmail.From = "support@chilkatsoft.com"
$oEmail.AddTo("John Doe","john@example.com")
$oEmail.AddPlainTextAlternativeBody("this is a test")
$oEmail.AddHtmlAlternativeBody("<html><body><b>Hello John!</b><p>This is a test</p></body></html>")
$bSuccess = $oEmail.AddFileAttachment2("qa_data/jpg/starfish.jpg","image/jpeg")

;  Check this email by implementing this curl command:

;  curl -X POST "https://spamcheck.postmarkapp.com/filter"
;  -H "Accept: application/json"
;  -H "Content-Type: application/json"
;  -v
;  -d '{"email":"raw dump of email", "options":"short"}'

$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("email",$oEmail.GetMime())
$oJson.UpdateString("options","short")

$oHttp = ObjCreate("Chilkat.Http")
$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpJson("POST","https://spamcheck.postmarkapp.com/filter",$oJson,"application/json",$oResp)
If ($bSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite("response status code = " & $oResp.StatusCode & @CRLF)
ConsoleWrite("response body: " & @CRLF)
ConsoleWrite($oResp.BodyStr & @CRLF)