Back to product page

Encrypt Method


Digitally encrypts the message.

Syntax

  • Basic
object.Encrypt (RecipientCert)
The Encrypt(object,RecipientCert) syntax has these parts:
objectAn expression evaluating to an object of type SmtpMsg
RecipientCertRequired. A Variant value. Reference to ICertificate instance that holds certificate of person that will receive the message.

Remarks

Encrypt method will digitally encrypt your message before it's delivered to the recipient. You need valid certificate of the recipient in order to encrypt a message. Messages are encrypted using S/MIME version 3 specification, and only intended recipient (one who has the private key that corresponds the certificate used in encryption process) can decrypt and open the message.

Typical usage will be like this:
       ' initialize wodSmtp and create some message
       Dim Smtp1 As New wodSmtpCom
       Smtp1.CreateSimple "someone@somehost.com", "recipient@otherhost.com", "Subject goes here", "Text goes here"
 
       ' now initialize certificate and load your personal certificate
       Dim cert As New Certificate
       cert.Load "c:\mbx\joe.pfx"
 
       'and encrypt the message
       Smtp1.Message.Encrypt cert
 
       ' optionally, save the message
       Smtp1.Message.Save App.Path & "\encrypted.eml"

above code will create new message and encrypt it using certificate stored in PFX file.

wodSmtp can also use certificates stored in Windows certificate store, so this code can also be used to encrypt the message:
       Dim cert As New CertLocation
       Smtp1.Message.Encrypt cert(CurrentUser).Item("AddressBook").Item("John Doe")


Platforms

Windows