This property specifies the certificates of recipients to encrypt current email.
ANSMTP uses CAPICOM object(a free component of Microsoft) to sign and encrypt email, CAPICOM is included in ANSMTP installation package. More detail about CAPICOM, please click here.
After you destroyed the Signer object or you no longer want to use Digital Signature, you should set Signer property to null.You must assign each certificate for each recipient.
Usage Example:
[Visual Baisc]
Private Sub SendEmail()
Dim oSmtp As New AOSMTPLib.Mail
Dim oStore As New CAPICOM.Store
Dim oCertificates As New CAPICOM.Certificates
Dim oRecipientCerts As New CAPICOM.Certificates
Dim oRecipientCert As CAPICOM.Certificate
Dim oCertificate As New CAPICOM.Certificate
Dim oSigner As New CAPICOM.Signer
Dim Sender As String
Sender = "test@adminsystem.net"
oCertificate.Load "c:\\cert\\my.pfx", "password of this certificate"
oSigner.Certificate = oCertificate
oSmtp.Signer = oSigner 'sign message
oSmtp.ServerAddr = "mail.adminsystem.net"
oSmtp.FromAddr = Sender
Dim arRecipients(3) As String
arRecipients(0) = "support@adminsystem.net"
arRecipients(1) = "support1@adminsystem.net"
arRecipients(2) = "support2@adminsystem.net"
Dim i, nCount As Long
nCount = 3
oStore.Open CAPICOM_CURRENT_USER_STORE, "My", CAPICOM_STORE_OPEN_READ_ONLY
For i = 0 To nCount - 1
Set oCertificates = oStore.Certificates.Find( _
CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME, _
arRecipients(i) )
If oCertificates.Count = 0 Then
MsgBox "no certificate found for " & arRecipients(i)
Exit Sub
End If
Set oRecipientCert = oCertificates.Item(1)
oRecipientsCerts.Add oRecipientCert
oSmtp.AddRecipient arRecipients(i), arRecipients(i), 0
Next
oSmtp.RecipientCerts = oRecipientCerts 'encrypt message
oSmtp.Subject = "Test"
oSmtp.BodyText = "Hello, this is a test...."
If oSmtp.SendMail() = 0 Then
MsgBox "Message delivered!"
Else
MsgBox oSmtp.GetLastErrDescription()
End If
oSmtp.Signer = Nothing
oSmtp.RecipientsCerts = Nothing
Set oSigner = Nothing
Set oRecipientCerts = Nothing
End Sub
See Also
2001-2007 © Copyright AdminSystem Software Limited. All rights reserved.