Sample code for 30+ languages & platforms
Visual Basic 6.0 Requires Chilkat v11.8.0+

Demonstrates how to call AddPemSource for an Email Object

Demonstrates how to call AddPemSource for an Email Object, with PEM text that was read into a string.

Chilkat Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

'  The PEM text (a certificate and its private key) is read into a string.
Dim fac As New CkFileAccess
Dim pemText As String
pemText = fac.ReadEntireTextFile("qa_data/pem/some.pem","utf-8")

'  Load the PEM text into a Pem object.  The 2nd argument of LoadPem is the password of the
'  private key.  (Pass an empty string if the private key is not encrypted.)
Dim pem As New ChilkatPem
success = pem.LoadPem(pemText,"PEM_PASSWORD")
If (success <> 1) Then
    Debug.Print pem.LastErrorText
    Exit Sub
End If

Dim email As New ChilkatEmail

success = email.AddPemSource(pem)
If (success <> 1) Then
    Debug.Print email.LastErrorText
    Exit Sub
End If

Debug.Print "Success."