Encrypt Method


Encrypts the message with the public keys contained in the recipient's certificates which were selected earlier using the AddRecipientCert method.


[Visual Basic]

blnResult = ObjectName.Encrypt

 
Parameters: None 
Return value As Boolean True if successful, False if error has occurred.  
Remarks:

The recipients can decrypt the encrypted message using their private keys. The developer can use the Encrypted property to check if the message is encrypted.


Usage example:

' This example loads the message from file and encrypts it with recipient's certificate. It also shows the code of the error if it occurred.

Dim objSMIME, objMsg

' Using Visual Basic to create the objects
Set objMsg = CreateObject("MailBee.Message")
Set objSMIME = CreateObject("MailBee.SMIME")
' Using ASP to create the objects
'Set objMsg = Server.CreateObject("MailBee.Message")
'Set objSMIME = Server.CreateObject("MailBee.SMIME")

' Specify MailBee license key
objSMIME.LicenseKey = "put your license key here"

' Load the  message from file
objMsg.ImportFromFile "mail_src.eml"

' Specify the message for the further processing
Set objSMIME.Message = objMsg

' Add recipient's certificate to certificate's list
If objSMIME.AddRecipientCert ("AddressBook", 0, "", "", "", objMsg.PureToAddr) Then
	' Encrypt the message
	objSMIME.Encrypt
End If

' Check if any errors occurred
If (objSMIME.SMIMEError <> SMIME_OK) Or (objSMIME.SMIMESpecificError <> SMIME_OK) Then
	' Display the code of the last occurred error
	' In ASP use Response.Write instead of MsgBox
    MsgBox "SMIMEError = " & objSMIME.SMIMEError & "   SMIMESpecificError = " & _
      objSMIME.SMIMESpecificError
End If


See Also:

SignAndEncrypt Method


Copyright © 2002-2022, AfterLogic Corporation. All rights reserved.