Chilkat ActiveX Components

  Chilkat .NET Components

  Chilkat C++ Libraries

Email SMTP .NET Component .NET SMTP / POP3 Email Component

ASP.NET SMTP Send Example Source Code Snippets

The full source code for these examples are provided in the ChilkatDotNet.msi download at http://www.chilkatsoft.com/downloads.asp

ASP.NET SMTP: Send a Digitally Signed Email using a Certificate

    '=======================================================================================
    '
    ' Example 5
    '
    ' Send a digitally signed email
    '
    ' For this example, our email will be very simple -- just a plain text email with
    ' no attachments.  However, when a signed email is sent, everything is included in
    ' creating the digital signature -- all attachments, HTML images, etc.
    ' So if anything is altered, the recipient will be notified (assuming the email
    ' client is capable of handling digitally signed emails).
    '
    '=======================================================================================

    ' 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 digitally signed email!")

    ' Our body is plain text, so give it a simple body:
    email.Body = "This is a plain-text, digitally signed email" + vbcrlf + "I hope that was easy!"
    
    email.SendSigned = true

    Dim cert as New Chilkat.Cert
    cert.SetFromEncoded(Request.form("signCert"))

    email.SetSigningCert(cert)


    ' 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

 

Copyright 2000-2005 Chilkat Software, Inc. All rights reserved.
Components for Microsoft Windows XP, 2000, NT, 95/98/ME