Specifies the connection type to smtp server.
[Visual Basic] Public Enum SmtpConnectType
[C#] public enum SmtpConnectType
[C++] __value public enum SmtpConnectType
[JScript] public enum SmtpConnectType
Members
Members name | Description |
ConnectNormal | Specifies that the smtp server uses normal TCP/IP connection. |
ConnectSSLAuto | Specifies that the smtp client selects the STARTTLS/Direct SSL automatically. |
ConnectSTARTTLS | Specifies that the smtp server deploys SSL connection by STARTTLS command. |
ConnectDirectSSL | Specifies that the smtp server deploys SSL connection directly. |
ConnectTryTLS | If smtp server supports TLS, then TLS connection is used; otherwise, normal TCP connection is used. |
TLS 1.2 Encryption
TLS is the successor of SSL, EASendMail supports SSL 3.0/TLS1.0 - 1.2 very well. In EASendMail, ConnectSTARTTLS doesn't mean TLS encryption, it means STARTTLS command in SMTP protocol.
You don't have to set any property to enable TLS 1.2 encryption. If your server requires TLS 1.2 encryption, TLS 1.2 encryption is used automatically with ConnectSSLAuto, ConnectSTARTTLS or ConnectDirectSSL.
To enable TLS 1.2 on Windows 2008/2008 R2/7, please install this update:
https://www.microsoft.com/security/blog/2017/07/20/tls-1-2-support-added-to-windows-server-2008/
Examples
[Visual Basic, C#, JavaScript] The following example demonstrates how to send email in Windows 8 Store App. To get the full samples of EASendMail, please refer to Samples section.
[C# - Send Email over SSL/TLS from Windows Store Apps - XAML] using EASendMail; using System.Threading.Tasks; private async Task SendEmail() { String Result = ""; try { SmtpMail oMail = new SmtpMail("TryIt"); SmtpClient oSmtp = new SmtpClient(); // Set sender email address, please change it to yours oMail.From = new MailAddress("test@emailarchitect.net"); // Add recipient email address, please change it to yours oMail.To.Add(new MailAddress("support@emailarchitect.net")); // Set email subject oMail.Subject = "test email from C# XAML project"; // Set email body oMail.TextBody = "this is a test email sent from Windows Store App, do not reply"; // Your SMTP server address SmtpServer oServer = new SmtpServer("smtp.emailarchitect.net"); // User and password for ESMTP authentication oServer.User = "test@emailarchitect.net"; oServer.Password = "testpassword"; // Enable SSL/TLS Connection oServer.ConnectType = SmtpConnectType.ConnectSSLAuto; // If your SMTP server requires SSL connection on 465 port, please add this line // oServer.Port = 465; await oSmtp.SendMailAsync(oServer, oMail); Result = "Email was sent successfully!"; } catch (Exception ep) { Result = String.Format("Failed to send email with the following error: {0}", ep.Message); } // Display Result by Diaglog box Windows.UI.Popups.MessageDialog dlg = new Windows.UI.Popups.MessageDialog(Result); await dlg.ShowAsync(); } [VB - Send Email over SSL/TLS from Windows Store Apps - XAML] Imports EASendMail Private Async Function SendEmail() As Task Dim Result As String = "" Try Dim oMail As New SmtpMail("TryIt") Dim oSmtp As New SmtpClient() ' Set sender email address, please change it to yours oMail.From = New MailAddress("test@emailarchitect.net") ' Add recipient email address, please change it to yours oMail.To.Add(New MailAddress("support@emailarchitect.net")) ' Set email subject oMail.Subject = "test email from VB XAML project" ' Set email body oMail.TextBody = "this is a test email sent from Windows Store App, do not reply" ' Your SMTP server address Dim oServer As New SmtpServer("smtp.emailarchitect.net") ' User and password for ESMTP authentication oServer.User = "test@emailarchitect.net" oServer.Password = "testpassword" ' Enable SSL/TLS Connection oServer.ConnectType = SmtpConnectType.ConnectSSLAuto ' If your SMTP server requires SSL connection on 465 port, please add this line ' oServer.Port = 465 Await oSmtp.SendMailAsync(oServer, oMail) Result = "Email was sent successfully!" Catch ep As Exception Result = String.Format("Failed to send email with the following error: {0}", ep.Message) End Try ' Display Result by Diaglog box Dim dlg As New Windows.UI.Popups.MessageDialog(Result) Await dlg.ShowAsync() End Function [JavaScript - Send Email over SSL/TLS from Windows Store Apps - HTML5] function sendMail() { var result = ""; var oMail = new EASendMail.SmtpMail("TryIt"); var oSmtp = new EASendMail.SmtpClient(); // Set sender email address, please change it to yours oMail.from = new EASendMail.MailAddress("test@emailarchitect.net"); // Add recipient email address, please change it to yours oMail.to.add(new EASendMail.MailAddress("support@emailarchitect.net")); // Set email subject oMail.subject = "test email from JavaScript HTML5 project"; // Set email body oMail.textBody = "this is a test email sent from Windows Store App, do not reply"; // Your SMTP server address var oServer = new EASendMail.SmtpServer("smtp.emailarchitect.net"); // User and password for ESMTP authentication oServer.user = "test@emailarchitect.net"; oServer.password = "testpassword"; // Enable SSL/TLS Connection oServer.connectType = EASendMail.SmtpConnectType.connectSSLAuto; // If your SMTP server requires SSL connection on 465 port, please add this line // oServer.port = 465; oSmtp.sendMailAsync(oServer, oMail).then(function (e) { result = "Email was sent successfully!"; // Display Result by Diaglog box (new Windows.UI.Popups.MessageDialog(result, "Success")).showAsync(); }, function (e) { // because javascript exception only gives the stack trace messages, but it is not // real description of exception, so we give a property lastErrorMessage for javascript. if (oSmtp.lastErrorMessage != "") { result = oSmtp.lastErrorMessage; } else { result = e.message; } oSmtp.close(); // Display Result by Diaglog box (new Windows.UI.Popups.MessageDialog(result, "Error Information")).showAsync(); }); }
See Also
SmtpServer.ConnectType Property
User Authentication and SSL Connection
From, ReplyTo, Sender and Return-Path