Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicPythonRubySQL ServerSwiftTclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.js

C# Examples

Async
Certificates
ECC
Email Object
Encryption
FTP
HTML-to-XML/Text
Gzip
HTTP
IMAP
JSON
MHT / HTML Email
PEM
PFX/P12
Java KeyStore (JKS)
POP3
RSA Encryption
MIME
REST
SCP
SMTP
Socket/SSL/TLS
SSH Key
SSH
SFTP
Stream
Tar Archive
XML
XMP
Zip

More Examples...
Google APIs
Google Cloud Storage
Azure Cloud Storage
Amazon S3 (new)
Google Drive
ASN.1
PRNG
Amazon S3
Bounced Email
CSV
Diffie-Hellman
DKIM / DomainKey
DSA
NTLM
QuickBooks

 

 

 

 

 

 

 

Using StartTLS to Send Email over a Secure Connection

Download: Chilkat .NET Assemblies

How to send email securely over a secure SSL/TLS connection using StartTLS (in C#).

        // Send email using SMTP StartTLS
        // IMPORTANT: Check to make sure your SMTP server supports STARTTLS.
        private void button3_Click(object sender, EventArgs e)
        {
            Chilkat.MailMan mailman = new Chilkat.MailMan();
            mailman.UnlockComponent("anything for 30-day trial");

            mailman.SmtpHost = "smtp.comcast.net";

            // If your SMTP server requires authentication, set your username/password:
            mailman.SmtpUsername = "myUsername";
            mailman.SmtpPassword = "myPassword";

            // The code for using STARTTLS is identical to sending mail over
            // an unsecure connection except that you need to set the
            // mailman.StartTLS property = true
            mailman.StartTLS = true;

            Chilkat.Email email = new Chilkat.Email();
            email.From = "Matt <matt@chilkatsoft.com>";
            email.Subject = "Subject for C# STARTTLS mail programming sample";
            email.Body = "Body for C# STARTTLS e-mail example code";
            email.AddTo("Email Component Help", "support@chilkatsoft.com");
            email.AddFileAttachment("someFile.pdf");

            // The SendEmail method will connect to the SMTP server using
            // the default (unsecure) port 25.  Because StartTLS is true, it will
            // negotiate a secure SSL/TLS connection immediately after connecting.
            // If authentication is required, it will occur over the secure connection.
            // The mail, including all attachments, will be sent over the secure connection also.
            bool success = mailman.SendEmail(email);
            if (!success)
            {
                MessageBox.Show(mailman.LastErrorText);
            }
            else
            {
                MessageBox.Show("Mail Sent!");
            }
        }

Important: The download for this example does not contain the ChilkatDotNet.dll which
must be downloaded and installed separately at http://www.chilkatsoft.com/downloads.asp.
Once installed, add a reference to the DLL in the project by following the instructions at
http://www.example-code.com/vbdotnet/step2.asp

 

© 2000-2016 Chilkat Software, Inc. All Rights Reserved.