EASendMail namespace contains classes that allow you to construct and send email messages. Email message is delivered through either arbitrary SMTP email service. The classes in this namespace can be used from XAML or HTML5 Windows Store App.
Classes
Class | Description |
Attachment | Provides properties and methods for constructing an e-mail attachment. |
AddressCollection | Collection of MailAddress class inherited from System.Collections.Generic.IList<MailAddress> |
HeaderCollection | Collection of HeaderItem class inherited from System.Collections.Generic.IList<HeaderItem> |
HeaderItem | Provides properties and methods for constructing an e-mail header. |
MailAddress | Provides properties and methods for constructing an e-mail address including display name, e-mail address and digital certificate. |
MimePart | Provides properties and methods for constructing a customized MIME part defined in RFC822. |
MimePartCollection | Collection of MimePart class inherited from System.Collections.Generic.IList<MimePart> |
SmtpClient | Provides properties and methods for sending messages and testing recipients. |
SmtpMail | Provides properties and methods for constructing an e-mail message. |
SmtpServer | Provides properties and methods for constructing a smtp server instance. |
Enumerations
Enumeration | Description |
DeliveryNotificationOptions | Provides enumered values for e-mail notification setting. |
HeaderEncodingType | Provides enumered values for e-mail header, subject, e-mail friendly name encoding. |
ImportHtmlBodyOptions | Provides enumered values for options of importing html body. |
ImportTextBodyOptions | Provides enumered values for options of importing plain text body. |
MailPriority | Specifies the priority level for the e-mail message. |
ServerProtocol | Specifies the protocol (SMTP/Exchange EWS/Exchange WebDAV) for mail server. |
SmtpAuthType | Specifies the smtp user authentication mechanism. |
SmtpConnectType | Specifies the connection type to smtp server. |
TransferEncodingType | Provides enumered values for e-mail body text encoding. |
Example
[Visual Basic, C#, JavaScript] The following example demonstrates how to send email with EASendMail SMTP Component, but it doesn't demonstrates the events usage. To get the full samples of EASendMail, please refer to Samples section.
[C# - Send Email 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")); // Add more recipient email address // oMail.To.Add(new MailAddress("supportex@emailarchitect.net")); // Add CC recipient email address // oMail.Cc.Add(new MailAddress("cc@emailarchitect.net")); // Add BCC recipient email address // oMail.Bcc.Add(new MailAddress("cc@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"; // If your SMTP server requires TLS connection on 25 port, please add this line // oServer.ConnectType = SmtpConnectType.ConnectSSLAuto; // If your SMTP server requires SSL connection on 465 port, please add this line // oServer.Port = 465; // oServer.ConnectType = SmtpConnectType.ConnectSSLAuto; 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 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")) ' Add more recipient email address ' oMail.To.Add(New MailAddress("supportex@emailarchitect.net")) ' Add CC recipient email address ' oMail.Cc.Add(New MailAddress("cc@emailarchitect.net")) ' Add BCC recipient email address ' oMail.Bcc.Add(New MailAddress("cc@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" ' If your SMTP server requires TLS connection on 25 port, please add this line ' oServer.ConnectType = SmtpConnectType.ConnectSSLAuto ' If your SMTP server requires SSL connection on 465 port, please add this line ' oServer.Port = 465 ' oServer.ConnectType = SmtpConnectType.ConnectSSLAuto 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 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")); // Add more recipient email address // oMail.to.add(new EASendMail.MailAddress("supportex@emailarchitect.net")); // Add CC recipient email address // oMail.cc.add(new EASendMail.MailAddress("cc@emailarchitect.net")); // Add BCC recipient email address // oMail.bcc.add(new EASendMail.MailAddress("cc@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"; // If your SMTP server requires TLS connection on 25 port, please add this line // oServer.connectType = EASendMail.SmtpConnectType.connectSSLAuto; // If your SMTP server requires SSL connection on 465 port, please add this line // oServer.port = 465; // oServer.connectType = EASendMail.SmtpConnectType.connectSSLAuto; 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
Using EASendMail SMTP Windows 8 Runtime Component in Windows Store Apps
User Authentication and SSL Connection
From, ReplyTo, Sender and Return-Path
EASendMail Windows 8 Runtime Component References
EASendMail SMTP Component Samples
Online Tutorials
Send Email in VB - Windows Store App
Send Email in C# - Windows Store App
Send Email in JavaScript - Windows Store App