Sample code for 30+ languages & platforms
PowerShell 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 PowerShell Downloads

PowerShell
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"

$success = $false

#  Assumes Chilkat is unlocked. See Global Unlock Sample.

$email = New-Object Chilkat.Email
$email.From = "Workshop team <events@example.com>"
$success = $email.AddTo("Alex Rivera","alex@example.net")
if ($success -ne $true) {
    $($email.LastErrorText)
    exit
}

$email.Subject = "Workshop registration"
$email.Body = "Your workshop registration is confirmed."
$request = New-Object Chilkat.JsonObject
$request.UpdateString("email",$email.GetMime())
$request.UpdateString("options","short")
$http = New-Object Chilkat.Http
$http.RequireSslCertVerify = $true
$resp = New-Object Chilkat.HttpResponse
$success = $http.HttpJson("POST","https://spamcheck.postmarkapp.com/filter",$request,"application/json",$resp)
if (($success -ne $true) -or ($resp.StatusCode -ne 200)) {
    $("SpamCheck request failed. HTTP " + $resp.StatusCode)
    exit
}

$result = New-Object Chilkat.JsonObject
$success = $result.Load($resp.BodyStr)
if ($success -ne $true) {
    $($result.LastErrorText)
    exit
}

if ($result.BoolOf("success") -ne $true) {
    $($result.StringOf("message"))
    exit
}

$("SpamAssassin score: " + $result.StringOf("score"))