ServerProtocol Enumeration


Specifies the protocol (SMTP/Exchange Web Service/Exchange WebDAV) for mail server.

[Visual Basic]
Public Enum ServerProtocol
[C#]
public enum ServerProtocol
[C++]
__value public enum ServerProtocol
[JScript]
public enum ServerProtocol

Members

Members name Description
SMTP Specifies that the mail server uses standard SMTP protocol.
ExchangeEWS Specifies that that the mail server uses Exchange Web Service protocol. Exchange 2007 or later version supports this protocol.
ExchangeWebDav Specifies that that the mail server uses Exchange Web Dav protocol. Exchange 2000/2003 supports this protocol.

Remarks

Standard SMTP protocol is always recommended.

Example

[Visual Basic, C#, C++] The following example demonstrates how to send email with SmtpClient class. To get the full samples of EASendMail, please refer to Samples section.

Example

[Visual Basic, C#, C++] To get the full samples of EASendMail, please refer to Samples section.

[Visual Basic - Send Email using Stanard SMTP Protocol]
Imports EASendMail
Sub SendMail_SMTP()
    Dim oMail As New SmtpMail("TryIt")
    Dim oSmtp As New SmtpClient()

    ' Set sender email address, please change it to yours
    oMail.From = "test@emailarchitect.net"

    ' Set recipient email address, please change it to yours
    oMail.To = "support@emailarchitect.net"
        
    ' Set email subject
    oMail.Subject = "test email from VB.NET project"
        
    ' Set email body
    oMail.TextBody = "this is a test email sent from VB.NET project, do not reply"

    ' Your SMTP server address
    Dim oServer As New SmtpServer("smtp.emailarchitect.net")
        
    ' User and password for ESMTP authentication, if your server doesn't require
    ' User authentication, please remove the following codes.            
    oServer.User = "test@emailarchitect.net"
    oServer.Password = "testpassword"

    ' If your smtp server requires SSL connection, please add this line
    ' oServer.ConnectType = SmtpConnectType.ConnectSSLAuto

    Try

        Console.WriteLine("start to send email ...")
        oSmtp.SendMail(oServer, oMail)
        Console.WriteLine("email was sent successfully!")

    Catch ep As Exception

        Console.WriteLine("failed to send email with the following error:")
        Console.WriteLine(ep.Message)
    End Try

End Sub

[Visual Basic - Send Email using Exchange Web Service - EWS]
Imports EASendMail
Sub SendMail_Exchange_EWS()
    Dim oMail As New SmtpMail("TryIt")
    Dim oSmtp As New SmtpClient()

    ' Set sender email address, please change it to yours
    oMail.From = "test@emailarchitect.net"

    ' Set recipient email address, please change it to yours
    oMail.To = "support@emailarchitect.net"
        
    ' Set email subject
    oMail.Subject = "test email from VB.NET project"
        
    ' Set email body
    oMail.TextBody = "this is a test email sent from VB.NET project, do not reply"

    ' Your Exchange server address
    Dim oServer As New SmtpServer("exch.emailarchitect.net")

    ' Set Exchange Web Service protocol (EWS) - Exchange 2007/2010 
    oServer.Protocol = ServerProtocol.ExchangeEWS
        
    ' User and password for Exchange User authentication        
    oServer.User = "emailarchitect.net\test"
    oServer.Password = "testpassword"

    ' By default, Exchange Web Service requires SSL connection
    oServer.ConnectType = SmtpConnectType.ConnectSSLAuto

    Try

        Console.WriteLine("start to send email ...")
        oSmtp.SendMail(oServer, oMail)
        Console.WriteLine("email was sent successfully!")

    Catch ep As Exception

        Console.WriteLine("failed to send email with the following error:")
        Console.WriteLine(ep.Message)
    End Try

End Sub

[Visual Basic - Send Email using Exchange WebDAV]
Imports EASendMail
Sub SendMail_Exchange_WebDav()
    Dim oMail As New SmtpMail("TryIt")
    Dim oSmtp As New SmtpClient()

    ' Set sender email address, please change it to yours
    oMail.From = "test@emailarchitect.net"

    ' Set recipient email address, please change it to yours
    oMail.To = "support@emailarchitect.net"
        
    ' Set email subject
    oMail.Subject = "test email from VB.NET project"
        
    ' Set email body
    oMail.TextBody = "this is a test email sent from VB.NET project, do not reply"

    ' Your Exchange server address
    Dim oServer As New SmtpServer("exch.emailarchitect.net")

    ' Set Exchange WebDAV protocol (EWS) - Exchange 2000/2003 
    oServer.Protocol = ServerProtocol.ExchangeWebDav
        
    ' User and password for Exchange User authentication        
    oServer.User = "emailarchitect.net\test"
    oServer.Password = "testpassword"

    ' If Exchange WebDav requires SSL connection, please add this line
    ' oServer.ConnectType = SmtpConnectType.ConnectSSLAuto

    Try

        Console.WriteLine("start to send email ...")
        oSmtp.SendMail(oServer, oMail)
        Console.WriteLine("email was sent successfully!")

    Catch ep As Exception

        Console.WriteLine("failed to send email with the following error:")
        Console.WriteLine(ep.Message)
    End Try

End Sub

[C# - Send Email using Standard SMTP protocol]
using System;
using EASendMail;
void SendMail_SMTP()
{
    SmtpMail oMail = new SmtpMail("TryIt");
    SmtpClient oSmtp = new SmtpClient();
        
    // Set sender email address, please change it to yours
    oMail.From = "test@emailarchitect.net";

    // Set recipient email address, please change it to yours
    oMail.To = "support@emailarchitect.net";
            
    // Set email subject
    oMail.Subject = "test email from c# project";
            
    // Set email body
    oMail.TextBody = "this is a test email sent from c# project, do not reply";
 
    // Your SMTP server address
    SmtpServer oServer = new SmtpServer("smtp.emailarchitect.net");

    // User and password for ESMTP authentication, if your server doesn't require
    // User authentication, please remove the following codes.            
    oServer.User = "test@emailarchitect.net";
    oServer.Password = "testpassword";
 
    // If your smtp server requires SSL connection, please add this line
    // oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
 
    try
    {
        Console.WriteLine("start to send email ...");
        oSmtp.SendMail(oServer, oMail);
        Console.WriteLine("email was sent successfully!");
    }
    catch (Exception ep)
    {
        Console.WriteLine("failed to send email with the following error:");
        Console.WriteLine(ep.Message);
    }
}
        
[C# - Send Email using Exchange Web Service - EWS]
using System;
using EASendMail;
void SendMail_Exchange_EWS()
{
    SmtpMail oMail = new SmtpMail("TryIt");
    SmtpClient oSmtp = new SmtpClient();
        
    // Set sender email address, please change it to yours
    oMail.From = "test@emailarchitect.net";

    // Set recipient email address, please change it to yours
    oMail.To = "support@emailarchitect.net";
            
    // Set email subject
    oMail.Subject = "test email from c# project";
            
    // Set email body
    oMail.TextBody = "this is a test email sent from c# project, do not reply";
 
    // Your Exchange server address
    SmtpServer oServer = new SmtpServer("exch.emailarchitect.net");

    // Set Exchange Web Service protocol (EWS) - Exchange 2007/2010
    oServer.Protocol = ServerProtocol.ExchangeEWS;

    // User and password for Exchange authentication     
    oServer.User = "emailarchitect.net\\test";
    oServer.Password = "testpassword";
 
    // By default, Exchange Web Service requires SSL connection
    oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
 
    try
    {
        Console.WriteLine("start to send email ...");
        oSmtp.SendMail(oServer, oMail);
        Console.WriteLine("email was sent successfully!");
    }
    catch (Exception ep)
    {
        Console.WriteLine("failed to send email with the following error:");
        Console.WriteLine(ep.Message);
    }
}

[C# - Send Email using Exchange WebDAV]
using System;
using EASendMail;
void SendMail_Exchange_WebDav()
{
    SmtpMail oMail = new SmtpMail("TryIt");
    SmtpClient oSmtp = new SmtpClient();
        
    // Set sender email address, please change it to yours
    oMail.From = "test@emailarchitect.net";

    // Set recipient email address, please change it to yours
    oMail.To = "support@emailarchitect.net";
            
    // Set email subject
    oMail.Subject = "test email from c# project";
            
    // Set email body
    oMail.TextBody = "this is a test email sent from c# project, do not reply";
 
    // Your Exchange server address
    SmtpServer oServer = new SmtpServer("exch.emailarchitect.net");

    // Set Exchange WebDAV protocol (EWS) - Exchange 2000/2003
    oServer.Protocol = ServerProtocol.ExchangeWebDav;

    // User and password for Exchange authentication     
    oServer.User = "emailarchitect.net\\test";
    oServer.Password = "testpassword";
 
    // If your Exchange WebDav requires SSL connection, please add this line
    // oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
 
    try
    {
        Console.WriteLine("start to send email ...");
        oSmtp.SendMail(oServer, oMail);
        Console.WriteLine("email was sent successfully!");
    }
    catch (Exception ep)
    {
        Console.WriteLine("failed to send email with the following error:");
        Console.WriteLine(ep.Message);
    }
}

[C++ - Send Email using Standard SMTP Protocol]
using namespace System;
using namespace EASendMail;
void SendMail_SMTP()
{
    SmtpMail ^oMail = gcnew SmtpMail("TryIt");
    SmtpClient ^oSmtp = gcnew SmtpClient();

    // Set sender email address, please change it to yours
    oMail->From = "test@emailarchitect.net";

    // Set recipient email address, please change it to yours
    oMail->To = "support@emailarchitect.net";
    
    // Set email subject
    oMail->Subject = "test email from Managed C++ project";
    
    // Set email body
    oMail->TextBody = "this is a test email sent from Managed C++ project, do not reply";

    // Your SMTP server address
    SmtpServer ^oServer = gcnew SmtpServer("smtp.emailarchitect.net");

    // User and password for ESMTP authentication, if your server doesn't require
    // User authentication, please remove the following codes.           
    oServer->User = "test@emailarchitect.net";
    oServer->Password = "testpassword";

    // If your SMTP server requires SSL connection, please add this line
    // oServer->ConnectType = SmtpConnectType::ConnectSSLAuto; 

    try
    {
        Console::WriteLine("start to send email from Managed C++...");
        oSmtp->SendMail(oServer, oMail);
        Console::WriteLine("email was sent successfully!");
    }
    catch (Exception ^ep)
    {
        Console::WriteLine("failed to send email with the following error:");
        Console::WriteLine(ep->Message);
    }
}

[C++ - Send Email using Exchange Web Service - EWS]
using namespace System;
using namespace EASendMail;
void SendMail_Exchange_EWS()
{
    SmtpMail ^oMail = gcnew SmtpMail("TryIt");
    SmtpClient ^oSmtp = gcnew SmtpClient();

    // Set sender email address, please change it to yours
    oMail->From = "test@emailarchitect.net";

    // Set recipient email address, please change it to yours
    oMail->To = "support@emailarchitect.net";
    
    // Set email subject
    oMail->Subject = "test email from Managed C++ project";
    
    // Set email body
    oMail->TextBody = "this is a test email sent from Managed C++ project, do not reply";

    // Your Exchange server address
    SmtpServer ^oServer = gcnew SmtpServer("exch.emailarchitect.net");

    // Set Exchange Web Service Protocol - EWS - Exchange 2007/2010
    oServer->Protocol = ServerProtocol::ExchangeEWS;

    // User and password for Exchange Web Service authentication
    oServer->User = "emailarchitect.net\\test";
    oServer->Password = "testpassword";

    // By default, Exchange Web Service requires SSL connection.
    oServer->ConnectType = SmtpConnectType::ConnectSSLAuto;

    try
    {
        Console::WriteLine("start to send email from Managed C++...");
        oSmtp->SendMail(oServer, oMail);
        Console::WriteLine("email was sent successfully!");
    }
    catch (Exception ^ep)
    {
        Console::WriteLine("failed to send email with the following error:");
        Console::WriteLine(ep->Message);
    }
}

[C++ - Send Email using Exchange WebDAV]
using namespace System;
using namespace EASendMail;
void SendMail_Exchange_WebDav()
{
    SmtpMail ^oMail = gcnew SmtpMail("TryIt");
    SmtpClient ^oSmtp = gcnew SmtpClient();

    // Set sender email address, please change it to yours
    oMail->From = "test@emailarchitect.net";

    // Set recipient email address, please change it to yours
    oMail->To = "support@emailarchitect.net";
    
    // Set email subject
    oMail->Subject = "test email from Managed C++ project";
    
    // Set email body
    oMail->TextBody = "this is a test email sent from Managed C++ project, do not reply";

    // Your Exchange server address
    SmtpServer ^oServer = gcnew SmtpServer("exch.emailarchitect.net");

    // Set Exchange WebDav Protocol - Exchange 2000/2003
    oServer->Protocol = ServerProtocol::ExchangeWebDav;

    // User and password for Exchange WebDav authentication
    oServer->User = "emailarchitect.net\\test";
    oServer->Password = "testpassword";

    // If your WebDav service requires SSL connection, please add this line
    oServer->ConnectType = SmtpConnectType::ConnectSSLAuto;

    try
    {
        Console::WriteLine("start to send email from Managed C++...");
        oSmtp->SendMail(oServer, oMail);
        Console::WriteLine("email was sent successfully!");
    }
    catch (Exception ^ep)
    {
        Console::WriteLine("failed to send email with the following error:");
        Console::WriteLine(ep->Message);
    }
}

See Also

User Authentication and SSL Connection
From, ReplyTo, Sender and Return-Path
Process Bounced Email (Non-Delivery Report) and Email Tracking

Online Tutorial

Send Email over SSL/TLS in C#
Send Email using Gmail in C#
Send Email using Yahoo in C#
Send Email using Hotmail/Live in C#

Send Email over SSL/TLS in VB
Send Email using Gmail in VB
Send Email using Yahoo in VB
Send Email using Hotmail/Live in VB

Send Email over SSL/TLS in C++/CLI
Send Email using Gmail in C++/CLI
Send Email using Yahoo in C++/CLI
Send Email using Hotmail/Live in C++/CLI