Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Send 3DES Encrypted Mail in VB
This example shows how to send encrypted email in VB6. The Chilkat Mail component locates and uses the digital certificate that corresponds to the email address in the "To" header field. In general, if Outlook or Outlook Express is setup to send encrypted email to the same recipient, this should work. There are other ways of using certificates loaded from DER-encoded X.509 .cer files, or loading them directly from the registry certificate stores using the Chilkat certificate component. Chilkat Mail can send and receive signed and encrypted email standalone -- the Chilkat S/MIME component is not required.
' Send 3DES encrypted email in Visual Basic
Private Sub Command1_Click()
' Create a mailman object for sending mail.
Dim mailman As ChilkatMailMan2
Set mailman = New ChilkatMailMan2
mailman.UnlockComponent "Any string begins the 30-day trial"
mailman.SmtpHost = "smtp.earthlink.net"
' Only set username/password if your SMTP server requires a logon.
'mailman.SmtpUsername = "your_username"
'mailman.SmtpPassword = "your_password"
' Only set the login domain if your SMTP server uses integrated Windows authorization
' AND it is part of a domain.
'mailman.SmtpLoginDomain = "your_domain"
Dim email As ChilkatEmail2
Set email = New ChilkatEmail2
email.AddTo "Chilkat Support", "matt@chilkatsoft.com"
email.Subject = "This is the subject"
email.Body = "This is the body"
email.From = "me@chilkatsoft.com"
email.AddFileAttachment "sample.jpg"
' Chilkat Mail will locate the certificate that matches the email address
' in the "To" header field and encrypt using this certificate.
' In general, if you have Outlook setup correctly for sending encrypted email
' to a particular email address, this should also work.
email.SendEncrypted = 1
' Comment these lines out if you want to default to the
' Microsoft Base Cryptographic Provider and 40-bit RC2 encryption.
' The ChilkatCSP object provides full control over the encryption algorithms
' used to send signed mail.
Dim csp As ChilkatCSP
Set csp = New ChilkatCSP
csp.SetProviderMicrosoftEnhanced
csp.SetEncryptAlgorithm "3DES"
' Here is another example, but commented out.
'csp.SetProviderMicrosoftRsaAes
' Set the encryption algorithm to AES 128. If successful, the return value will be the key length. Returns 0 if failed.
'numbits = csp.SetEncryptAlgorithm("AES 128")
' If an explicit encryption algorithm is used (via the CSP object) then
' associate the CSP with the mail object.
email.SetCSP csp
' Send the mail...
success = mailman.SendEmail(email)
' If success is 0, errors can be retrieved from the log.
If (success = 1) Then
MsgBox "Encrypted email sent!"
Else
MsgBox mailman.LastErrorText
End If
End Sub
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.