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

C#
bool success = false;

//  Assumes Chilkat is unlocked. See Global Unlock Sample.

Chilkat.Email email = new Chilkat.Email();
email.From = "Workshop team <events@example.com>";
success = email.AddTo("Alex Rivera","alex@example.net");
if (success != true) {
    Debug.WriteLine(email.LastErrorText);
    return;
}

email.Subject = "Workshop registration";
email.Body = "Your workshop registration is confirmed.";
Chilkat.JsonObject request = new Chilkat.JsonObject();
request.UpdateString("email",email.GetMime());
request.UpdateString("options","short");
Chilkat.Http http = new Chilkat.Http();
http.RequireSslCertVerify = true;
Chilkat.HttpResponse resp = new Chilkat.HttpResponse();
success = http.HttpJson("POST","https://spamcheck.postmarkapp.com/filter",request,"application/json",resp);
if ((success != true) || (resp.StatusCode != 200)) {
    Debug.WriteLine("SpamCheck request failed. HTTP " + Convert.ToString(resp.StatusCode));
    return;
}

Chilkat.JsonObject result = new Chilkat.JsonObject();
success = result.Load(resp.BodyStr);
if (success != true) {
    Debug.WriteLine(result.LastErrorText);
    return;
}

if (result.BoolOf("success") != true) {
    Debug.WriteLine(result.StringOf("message"));
    return;
}

Debug.WriteLine("SpamAssassin score: " + result.StringOf("score"));