wodSmtp ActiveX Control - Encrypt Method
      
 

Description

Digitally encrypts the message.


Return Type

None  


Syntax

object.Encrypt RecipientCert



The Encrypt Method syntax has these parts:

Part Description
object An expression evaluating to an object of type SmtpMsg.
RecipientCert Required. 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")