SmtpServer.Alias Property


Sets another user alias used in Exchange WebDAV protocol.

[Visual Basic]
Public Property Alias As String
[C#]
public string Alias {get; set;}
[C++]
public: __property String^ get_Alias();
public: __property void set_Alias(String^);
[JScript]
public function get Alias() : String;
public function set Alias(String);

Property Value

A string value indicating the user alias for Exchange WebDAV.

Remarks

If you choose Exchange WebDAV protocol, EASendMail need to create and send email by a user mail folder. By default, the authenticated user mail folder is used. You can use this property to specify another user mail folder to be used, but your authenticated user MUST have the permission to access this user alias folder. This property is not recommended to be used.
For SMTP and Exchange Web Service protocol, you can simply ignore this property.

Example

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

[Visual Basic - Send Email with 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 - Exchange 2000/2003 
    oServer.Protocol = ServerProtocol.ExchangeWebDav
        
    ' Use administrator to do  Exchange User authentication        
    oServer.User = "administrator"
    oServer.Password = "administratorpassword"

    ' Use test user mail folder to send email
    oServer.Alias = "test"

    ' If Exchange WebDav requires SSL connection, please add this line
    ' oServer.ConnectType = SmtpConnectType.ConnectSSLAuto
    
    ' Set your Drafts folder name
    oServer.Drafts = "drafts"

    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 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 - Exchange 2000/2003
    oServer.Protocol = ServerProtocol.ExchangeWebDav;

    // Use administrator to do Exchange authentication     
    oServer.User = "administrator";
    oServer.Password = "administrator password";
 
    // Use test user mail folder to send email
    oServer.Alias = "test";

    // If your Exchange WebDav requires SSL connection, please add this line
    // oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
 
    // Set your Drafts folder name
    oServer.Drafts = "drafts";

    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 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;

    // Use administrator user to do Exchange WebDav authentication
    oServer->User = "administrator";
    oServer->Password = "administrator password";

    // Use test user mail folder to send email
    oServer->Alias = "test";

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

    // Set your Drafts folder name
    oServer->Drafts = "drafts";

    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

SmtpServer.Protocol Property
SmtpServer.Drafts Property
User Authentication and SSL Connection
Process Bounced Email (Non-Delivery Report) and Email Tracking

Online Tutorial

Send Email using Exchange WebDAV in C#
Send Email using Exchange WebDAV in VB

Send Email using Exchange Web Service in C#
Send Email using Exchange Web Service in VB