'=======================================================================================
'
' Example 6
'
' Send a digitally encrypted email
'
' For this example, our email will be very simple -- just a plain text email with
' no attachments. However, when an encrypted email is sent, everything
' is encrypted -- all attachments, HTML images, etc.
'
'=======================================================================================
' Create a Chilkat.MailMan object for sending,
' and set the necessary properties and unlock the component.
Dim mailman as New Chilkat.MailMan()
mailman.UnlockComponent(Request.form("unlockCode"))
' Tell the MailMan the SMTP server to be used for sending email.
mailman.SmtpHost = Request.form("smtpServer")
' Optionally provide the SMTP server with a login and password.
' The MailMan will automatically choose the most secure SMTP authorization
' method available.
if Request.form("smtpLogin") <> "" then
mailman.SmtpUsername = Request.form("smtpLogin")
mailman.SmtpPassword = Request.form("smtpPassword")
end if
' Create an Email object. The mailman will send the email.
Dim email As New Chilkat.Email()
' Give our email a subject, recipient, and return address.
email.From = Request.form("fromAddr")
email.AddTo("",Request.form("recipient"))
email.Subject = "Chilkat ASP.NET " + Request.form("exampleSelected")
Response.Write("Sending encrypted email!")
' Our body is plain text, so give it a simple body:
email.Body = "This is a plain-text, encrypted email" + vbcrlf + "I hope that was easy!"
email.SendEncrypted = true
Dim cert as New Chilkat.Cert
cert.SetFromEncoded(Request.form("encryptCert"))
email.SetEncryptCert(cert)
' Make sure we use something strong enough.
' The Microsoft Base Cryptographic Provider is the default,and it defaults to 40-bit RC2
' encryption, which is weak. The Enhanced Provider, which is most likely already on your
' computer, provides stonger default protection (128-bit). You can also optionally select
' 3DES encryption by uncommenting the line below.
Dim csp as New Chilkat.Csp
csp.SetProviderMicrosoftEnhanced
'csp.SetEncryptAlgorithm("3DES")
email.SetCSP(csp)
' Connect to the SMTP server and send mail.
if (mailman.SendEmail(email)) then
Response.write("Mail sent!")
else
Response.write("Errors in sending email!")
Response.write(mailman.LastErrorHtml)
end if
|