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

 

 

 

 

 

 

SMTP Authentication (NTLM, CRAM-MD5, LOGIN); SSL, STARTTLS

Download: Chilkat .NET Assemblies

C# example code describing SMTP authentication and SSL / STARTTLS options for protecting SMTP login and password transmissions.

    // This example discusses SMTP authentication
    //
    // If your SMTP server requires authentication, you will need
    // to set the Chilkat.MailMan.SmtpUsername and SmtpPassword properties.
    // NOTE: Some SMTP servers require authentication when your program
    // connects from outside a firewall, but do not require authentication
    // when connecting from within it's own network (i.e. on the same side
    // of the firewall as the SMTP server).
    //
    // The Chilkat.MailMan.SmtpAuthMethod can explicitly control the
    // authentication method used by the Chilkat email component.
    // By default, it is set to an empty string which indicates that
    // the most secure authentication method supported by the SMTP server
    // should be used.  This is typically NTLM or CRAM-MD5.
    // For most cases, you should never need to set the SmtpAuthMethod property.
    //
        
    // Create an instance of the mailman for the purpose of unlocking.
    Chilkat.MailMan mailman = new Chilkat.MailMan();
    mailman.UnlockComponent("Anything for 30-day trial");
    
    // Create a new email object...
    Chilkat.Email email = new Chilkat.Email();
    email.Subject = "This is a test";
    email.Body = "This is the mail body";
    email.AddTo("Chilkat Support", "support@chilkatsoft.com");
    email.From = "Chilkat Sales <sales@chilkatsoft.com>";
    
    mailman.SmtpHost = "smtp.comcast.net";

    // If the SMTP server does not require authentication, these two
    // lines can be omitted.
    mailman.SmtpUsername = "myLogin";
    mailman.SmtpPassword = "myPassword";
        
    // If there is a problem with authentication, the "LOGIN" method is surely supported:
    mailman.SmtpAuthMethod = "LOGIN";
    
    // However, if you use the "LOGIN" method of authentication, your SMTP username/password
    // is sent over the Internet unprotected.  A good way of solving this is to
    // use SMTP SSL:
    mailman.SmtpSsl = true;     // Tell the mailman to connect via SSL
    mailman.SmtpPort = 465;     // Most SMTP servers listen at port 465 for SSL connections.
    // Now you can use LOGIN authentication because everything is protected by the SSL connection.
    
    // An alternative is to use STARTTLS.  This means that the SMTP server is initially
    // connected on a normal, unsecure connect at the default SMTP port 25.
    mailman.SmtpSsl = false;
    mailman.SmtpPort = 25;
    mailman.StartTLS = true;
    // The StartTLS option causes the connection to be converted to an SSL/TLS connection
    // such that the authentication and mail sending occurs over a secure channel.
    
    success = mailman.SendEmail(email);
    if (!success)
    {
        MessageBox.Show(mailman.LastErrorText);
    }
    else
    {
        MessageBox.Show("Send Complete!");
    }

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.