Delphi Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Delphi Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
DH Key Exchange
DSA
Email
Email Object
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
SMTP
Socket
Spider
SFTP
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Byte Array
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate

Unreleased...
Bzip2
LZW
Icon

Type Conversion

 

Article: Understanding COM References in Delphi

Send Encrypted Email

Download Chilkat Email ActiveX

Send encrypted email in Delphi using a digital certificate.

{
  Sends an encrypted email using the digital certificate of the recipient.
  To send an encrypted email, you must have the certificate of the "To" recipient.
  It may be installed in the "Current User" or "Local Machine" certificate store
  which is located in the Windows registry, or a .cer certificate file may be used.
  A digitally encrypted email can only be opened by the recipient because
  he/she is the only one in possession of the certificate WITH a private key.
  If a program needs to send encrypted email to multiple recipients, it should
  send each email individually to each recipient.

  If the digital certificate is located in a registry-based certificate store,
  your program only needs to set the SendEncrypted property = 1.  The Chilkat
  email component will automatically locate the matching certificate and use
  it for encryption.
}
procedure TForm1.Button16Click(Sender: TObject);
var
  email: IChilkatEmail2;
  ok: Integer;

begin
  // A ChilkatMailMan2 ActiveX component was dropped onto the Delphi
  // form, and this became the Form's member variable "ChilkatMailMan21".

  ChilkatMailMan21.UnlockComponent('Anything for 30-day trial');
  ChilkatMailMan21.SmtpHost := 'smtp.comcast.net';

  email := ChilkatMailMan21.NewEmail();
  email.Subject := 'Encrypted email sent from a Delphi program!';
  email.From := 'Chilkat Support <support@chilkatsoft.com>';
  email.AddTo('Chilkat Admin','admin@tagtooga.com');
  email.Body := 'This encrypted email was mailed from a Delphi program...';

  // In this example, assume we have the certificate for "admin@tagtooga.com"
  // already installed.  If this is the case, we only need to do this:
  email.SendEncrypted := 1;

  ok := ChilkatMailMan21.SendEmail(email);
  if (ok = 0) then
        ChilkatMailMan21.SaveLastError('errorLog.xml');

  // We could also load a certificate from a .cer file and
  // use it explicitly.  Import the Chilkat Certificate ActiveX
  // (which is included in the Chilkat Mail download), and drop
  // a ChilkatCert object onto your form.  You will find the ChilkatCert
  // object under the ActiveX tab, along with the other Chilkat components.
  ChilkatCert1.LoadFromFile('tagtooga.cer');
  // When SetEncryptCert is called, the component will not search for the
  // matching certificate in the certificate stores, but will instead
  // use the encryption certificate you provide.
  email.SetEncryptCert(ChilkatCert1.ControlInterface as CHILKATMAILLib2_TLB.IChilkatCert);

  ok := ChilkatMailMan21.SendEmail(email);
  if (ok = 0) then
        ChilkatMailMan21.SaveLastError('errorLog.xml');


end;

 

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Email Component · XML Parser