|  | 
Chilkat  HOME  Android™  AutoIt  C  C#  C++  Chilkat2-Python  CkPython  Classic ASP  DataFlex  Delphi DLL  Go  Java  Node.js  Objective-C  PHP Extension  Perl  PowerBuilder  PowerShell  PureBasic  Ruby  SQL Server  Swift  Tcl  Unicode C  Unicode C++  VB.NET  VBScript  Visual Basic 6.0  Visual FoxPro  Xojo Plugin
| (Unicode C) Get SpamAssassin Score for an EmailUses Postmark’s spam API (a RESTfull interface to the SpamAssassin filter tool) to analyze an email to get a spam score. Note: This example requires Chilkat v11.0.0 or greater. 
 #include <C_CkEmailW.h> #include <C_CkJsonObjectW.h> #include <C_CkHttpW.h> #include <C_CkHttpResponseW.h> void ChilkatSample(void) { BOOL success; HCkEmailW email; HCkJsonObjectW json; HCkHttpW http; HCkHttpResponseW resp; success = 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. email = CkEmailW_Create(); CkEmailW_putSubject(email,L"this is a test"); CkEmailW_putFrom(email,L"support@chilkatsoft.com"); CkEmailW_AddTo(email,L"John Doe",L"john@example.com"); CkEmailW_AddPlainTextAlternativeBody(email,L"this is a test"); CkEmailW_AddHtmlAlternativeBody(email,L"<html><body><b>Hello John!</b><p>This is a test</p></body></html>"); success = CkEmailW_AddFileAttachment2(email,L"qa_data/jpg/starfish.jpg",L"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"}' json = CkJsonObjectW_Create(); CkJsonObjectW_UpdateString(json,L"email",CkEmailW_getMime(email)); CkJsonObjectW_UpdateString(json,L"options",L"short"); http = CkHttpW_Create(); resp = CkHttpResponseW_Create(); success = CkHttpW_HttpJson(http,L"POST",L"https://spamcheck.postmarkapp.com/filter",json,L"application/json",resp); if (success == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkEmailW_Dispose(email); CkJsonObjectW_Dispose(json); CkHttpW_Dispose(http); CkHttpResponseW_Dispose(resp); return; } wprintf(L"response status code = %d\n",CkHttpResponseW_getStatusCode(resp)); wprintf(L"response body: \n"); wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp)); CkEmailW_Dispose(email); CkJsonObjectW_Dispose(json); CkHttpW_Dispose(http); CkHttpResponseW_Dispose(resp); } | ||||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.