C# Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CUnicode C++Unicode CMFCDelphi DLLDelphi ActiveXFoxProJavaPerlPHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C# Examples

Bounced Mail
Bz2
Character Encoding
CSV
DKIM / DomainKey
Digital Certificates
Digital Signatures
Email
Email Object
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

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-2013 Chilkat Software, Inc. All Rights Reserved.