![]()  | 
  
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
 
      (Delphi DLL) Save Email Credentials in Apple Keychain or Windows Credentials ManagerSee more Apple Keychain ExamplesThis example demonstrates how to save (or update) email credentials in the Apple Keychain.
 uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Secrets, JsonObject; ... procedure TForm1.Button1Click(Sender: TObject); var secrets: HCkSecrets; json: HCkJsonObject; success: Boolean; begin // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. secrets := CkSecrets_Create(); // On Windows, this is the Windows Credentials Manager // On MacOS/iOS, it is the Apple Keychain CkSecrets_putLocation(secrets,'local_manager'); // Specify the name of the secret. // service and username are required. // appName and domain are optional. // Note: The values are arbitrary and can be anything you want. json := CkJsonObject_Create(); CkJsonObject_UpdateString(json,'appName','MyEmailApp'); CkJsonObject_UpdateString(json,'service','SMTP'); CkJsonObject_UpdateString(json,'domain','example.com'); CkJsonObject_UpdateString(json,'username','joe@example.com'); // Create or update the secret. // This secret is the SMTP password for the above email account. success := CkSecrets_UpdateSecretStr(secrets,json,'joes_password'); if (success = False) then begin Memo1.Lines.Add(CkSecrets__lastErrorText(secrets)); Exit; end; // Let's save the IMAP secret for an account we'll read using IMAP.. CkJsonObject_UpdateString(json,'appName','MyEmailApp'); CkJsonObject_UpdateString(json,'service','IMAP'); CkJsonObject_UpdateString(json,'domain','example2.com'); CkJsonObject_UpdateString(json,'username','jane@example2.com'); success := CkSecrets_UpdateSecretStr(secrets,json,'janes_password'); if (success = False) then begin Memo1.Lines.Add(CkSecrets__lastErrorText(secrets)); Exit; end; Memo1.Lines.Add('Success.'); CkSecrets_Dispose(secrets); CkJsonObject_Dispose(json); end;  | 
  ||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.