Delphi ActiveX Requires Chilkat v11.0.0+
Delphi ActiveX
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 Delphi ActiveX Downloads
var
success: Integer;
email: TChilkatEmail;
request: TChilkatJsonObject;
http: TChilkatHttp;
resp: TChilkatHttpResponse;
result: TChilkatJsonObject;
begin
success := 0;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
email := TChilkatEmail.Create(Self);
email.From := 'Workshop team <events@example.com>';
success := email.AddTo('Alex Rivera','alex@example.net');
if (success <> 1) then
begin
Memo1.Lines.Add(email.LastErrorText);
Exit;
end;
email.Subject := 'Workshop registration';
email.Body := 'Your workshop registration is confirmed.';
request := TChilkatJsonObject.Create(Self);
request.UpdateString('email',email.GetMime());
request.UpdateString('options','short');
http := TChilkatHttp.Create(Self);
http.RequireSslCertVerify := 1;
resp := TChilkatHttpResponse.Create(Self);
success := http.HttpJson('POST','https://spamcheck.postmarkapp.com/filter',request.ControlInterface,'application/json',resp.ControlInterface);
if ((success <> 1) or (resp.StatusCode <> 200)) then
begin
Memo1.Lines.Add('SpamCheck request failed. HTTP ' + IntToStr(resp.StatusCode));
Exit;
end;
result := TChilkatJsonObject.Create(Self);
success := result.Load(resp.BodyStr);
if (success <> 1) then
begin
Memo1.Lines.Add(result.LastErrorText);
Exit;
end;
if (result.BoolOf('success') <> 1) then
begin
Memo1.Lines.Add(result.StringOf('message'));
Exit;
end;
Memo1.Lines.Add('SpamAssassin score: ' + result.StringOf('score'));