Sample code for 30+ languages & platforms
Delphi ActiveX Requires Chilkat v11.0.0+

Sign an EML using RSA-PSS and SHA-256

See more Email Object Examples

Load the intended signing certificate and its RSA private key from a PFX. Set the signature options on Email and render the final S/MIME message through MailMan. The resulting multipart/signed file can be verified independently. Supply the PFX password through your application’s credential store.

Chilkat Delphi ActiveX Downloads

Delphi ActiveX
var
success: Integer;
email: TChilkatEmail;
cert: TChilkatCert;
mail: TChilkatMailMan;
rendered: TChilkatBinData;

begin
success := 0;

//  Assumes Chilkat is unlocked. See Global Unlock Sample.

email := TChilkatEmail.Create(Self);
success := email.LoadEml('message.eml');
if (success <> 1) then
  begin
    Memo1.Lines.Add(email.LastErrorText);
    Exit;
  end;
cert := TChilkatCert.Create(Self);
success := cert.LoadPfxFile('signer.pfx','PFX_PASSWORD');
if (success <> 1) then
  begin
    Memo1.Lines.Add(cert.LastErrorText);
    Exit;
  end;
success := email.SetSigningCert(cert.ControlInterface);
if (success <> 1) then
  begin
    Memo1.Lines.Add(email.LastErrorText);
    Exit;
  end;
email.SigningAlg := 'pss';
email.SigningHashAlg := 'sha256';
email.SendSigned := 1;
mail := TChilkatMailMan.Create(Self);
mail.OpaqueSigning := 0;
rendered := TChilkatBinData.Create(Self);
success := mail.RenderToMimeBd(email.ControlInterface,rendered.ControlInterface);
if (success <> 1) then
  begin
    Memo1.Lines.Add(mail.LastErrorText);
    Exit;
  end;
success := rendered.WriteFile('signed.eml');
if (success <> 1) then
  begin
    Memo1.Lines.Add('Failed: rendered.WriteFile.');
    Exit;
  end;
Memo1.Lines.Add('Saved signed.eml.');