Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Create S/MIME Detached Signature with PFXHow to use a PFX to create a signed S/MIME message. uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, CHILKATMIMELib_TLB, CHILKATCERTIFICATELib_TLB, OleCtrls; ... procedure TForm1.Button1Click(Sender: TObject); var mime: CHILKATMIMELib_TLB.IChilkatMime; success: Integer; certStore: CHILKATCERTIFICATELib_TLB.IChilkatCertStore; password: String; cert: IChilkatCert; begin mime := CoChilkatMime.Create(); success := mime.UnlockComponent('Anything for 30-day trial'); if (success = 0) then begin ShowMessage('Failed to unlock component'); end; mime.AddHeaderField('Subject','This is a test'); mime.AddHeaderField('Abc','123'); mime.SetBodyFromPlainText('This is the body'); certStore := CoChilkatCertStore.Create(); password := 'myPassword'; success := certStore.LoadPfxFile('chilkat.pfx',password); if (success = 0) then begin ShowMessage(certStore.LastErrorText); end; cert := certStore.FindCertBySubjectCN('Chilkat Software, Inc.'); if (cert = nil ) then begin ShowMessage('Failed to find certificate!'); end; // Display the full distinguished name of the cert. Memo1.Lines.Add(cert.SubjectDN); success := mime.AddDetachedSignature(cert); if (success = 0) then begin ShowMessage(mime.LastErrorText); end; Memo1.Lines.Add(mime.GetMime()); end; |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.