AddRecipientCert Method


Adds the certificate having the specified parameters to the list of certificates which are used for subsequent encryption of the message.

A mail message might be encrypted with the several recipient's public keys (contained in the matched certificates) according to the S/MIME standard. In that case, the recipients are able to decrypt this message using their private keys.


[Visual Basic]

blnResult = ObjectName.AddRecipientCert([Store], [StoreType], IssuedTo, IssuedBy, FriendlyName)

 
Parameters:  
Store As String

(optional) The name of the digital certificate's storage. The following names are supported for the system storage (REGISTRY_STORE):

  • "MY" - the personal user's certificates storage
  • "AddressBook" - other people certificates storage
  • "CA" - Intermediate Certification Authorities
  • "Root" - Trusted Root Certification Authorities

By default, this parameter is set to "AddressBook" value.

 
StoreType As Long

(optional) The type of the digital certificate's storage. MailBee supports the next types of the certificate's storages:

  • REGISTRY_STORE = 0 - standard system storage which belongs to the current user
  • FILE_STORE = 1 - file storage
  • FILE_PFX_STORE = 2 - file PFX storage (special file type)

By default, this parameter is set to REGISTRY_STORE value.

 
IssuedTo As String The name of a person or organization to whom the certificate was issued.  
IssuedBy As String The name of a person or organization by whom the certificate was issued.  
FriendlyName As String The friendly name of a person to whom the certificate was issued.  
Return value As Boolean True if successful, False if error has occurred.  

Usage example:

' This example loads the message from file, encrypts it and saves it to disk.
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 the recipient's certificate for the message encryption from the system storage objSMIME.AddRecipientCert "AddressBook", 0, "Thawte Freemail Member", "", "" ' Encrypt the message objSMIME.Encrypt ' 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 ' Get the encrypted message Set objMsg = objSMIME.Message ' Save the message to disk objMsg.SaveMessage "mail_dst.eml"

See Also:

SelectSenderCert Method, AddSignerToStore Method


Copyright 2002-2008, AfterLogic Corporation. All rights reserved.