Sample code for 30+ languages & platforms
PowerBuilder

Check if an Email Was Received Digitally Signed

See more Email Object Examples

Demonstrates the read-only Chilkat Email.ReceivedSigned property, which is true if the email was originally received carrying one or more digital signatures. Knowing a message was signed is separate from knowing the signature checked out, so this example also reads SignaturesValid to report whether the signed content verified.

Background: A digital signature on an email (S/MIME) provides two things: authenticity (it was really sent by the holder of a particular certificate) and integrity (the content was not altered in transit). The sender signs a hash of the message with their private key; the recipient verifies it with the sender's public certificate. ReceivedSigned simply tells you a signature is present — verifying it is a separate step exposed through SignaturesValid.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Email

li_Success = 0

//  Demonstrates the read-only Email.ReceivedSigned property, which is true if this
//  email was originally received with a digital signature.  Use SignaturesValid to
//  determine whether the signed content actually verified.

loo_Email = create oleobject
li_rc = loo_Email.ConnectToNewObject("Chilkat.Email")
if li_rc < 0 then
    destroy loo_Email
    MessageBox("Error","Connecting to COM object failed")
    return
end if

li_Success = loo_Email.LoadEml("qa_data/eml/signed.eml")
if li_Success = 0 then
    Write-Debug loo_Email.LastErrorText
    destroy loo_Email
    return
end if

if loo_Email.ReceivedSigned = 1 then
    Write-Debug "This email was received with a digital signature."
    if loo_Email.SignaturesValid = 1 then
        Write-Debug "All signatures are valid."
    else
        Write-Debug "One or more signatures are NOT valid."
    end if

else
    Write-Debug "This email was not signed."
end if

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


destroy loo_Email