Sample code for 30+ languages & platforms
SQL Server

Get the Signer Details of a Signed Email

See more Email Object Examples

Demonstrates the read-only Chilkat Email.SignedBy property. If the email was received digitally signed, this contains the fields of the signer certificate's Subject Distinguished Name, for example: US, 94105, California, San Francisco, 100 Market Street, Northwind Research LLC, Engineering, Avery Morgan. The values appear without the attribute-name prefixes (C=, ST=, L=, O=, CN=). It is intended for display or diagnostics; use LastSignerCert when the certificate object itself is needed.

Background: Every certificate identifies its owner with a Subject Distinguished Name (Subject DN) — a structured set of fields like Country (C), State (ST), Organization (O), and Common Name (CN). The CN is typically the person or entity the certificate was issued to. SignedBy gives you a human-readable rendering of that identity, which is handy for showing "who signed this?" without needing to parse the certificate yourself.

Chilkat SQL Server Downloads

SQL Server
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @success int
    SELECT @success = 0

    --  Demonstrates the read-only Email.SignedBy property.  If the email was received
    --  digitally signed, this contains the fields of the signer certificate's SubjectDN
    --  (without the C=, ST=, L=, O=, CN= attribute names).

    DECLARE @email int
    EXEC @hr = sp_OACreate 'Chilkat.Email', @email OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OAMethod @email, 'LoadEml', @success OUT, 'qa_data/eml/signed.eml'
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @email, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @email
        RETURN
      END

    EXEC sp_OAGetProperty @email, 'ReceivedSigned', @iTmp0 OUT
    IF @iTmp0 = 1
      BEGIN

        EXEC sp_OAGetProperty @email, 'SignedBy', @sTmp0 OUT
        PRINT 'Signed by: ' + @sTmp0
      END
    ELSE
      BEGIN

        PRINT 'This email was not signed.'
      END

    --  Note: Paths such as "qa_data/..." are relative local filesystem paths,
    --  relative to the current working directory of the running application.

    EXEC @hr = sp_OADestroy @email


END
GO