MailServer.Alias Property


Gets or sets the MS Exchange Server shared mailbox.

[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 shared mailbox. Only Exchange Web Service/WebDAV protocol supports this feature.

Remarks

By default, EAGetMail accesses current user mailbox on MS Exchange Server. If you want to access other user/shared mailbox on MS Exchange server rather than current user mailbox, please set the mailbox name to this property.

Example

[Visual Basic, C#, C++] The following example demonstrates how to receive email with EAGetMail POP3 & IMAP Component, but it doesn't demonstrates the events and mail parsing usage. To get the full samples of EAGetMail, please refer to Samples section.

[VB - Retrieve Email from Shared MailBox on Exchange Server]
Imports System
Imports System.Globalization
Imports System.IO
Imports System.Text
Imports EAGetMail

Public Sub RetrieveMail_from_SharedMailbox()

    Try
        ' Only Exchange WebDAV and Exchange Web Service support this feature.
        Dim oServer As New MailServer("myexchangeserveraddress", _
            "test@myexchange", "testpassword", true, _
            ServerAuthType.AuthLogin, ServerProtocol.ExchangeEWS)

        ' Set the mailbox to accesss, 
        ' Then you will access shared@exchange mailbox instead of test@exchange
        oServer.Alias = "shared@exchange" 

        ' WebDAV Example
        ' Dim oServer As New MailServer("myexchangeserveraddress", _ 
        '    "test@myexchange", "testpassword", false, _ 
        '    ServerAuthType.AuthLogin, ServerProtocol.ExchangeWebDAV) 

        ' Set the mailbox to accesss, please don't append domain with WebDAV protocol
        ' Then you will access shared@exchange mailbox instead of test@exchange
        ' oServer.Alias = "shared" 
        
        Dim oClient As New MailClient("TryIt")
        oClient.Connect(oServer)

        Dim infos() As MailInfo = oClient.GetMailInfos()
        For i As Integer = 0 To infos.Length - 1
            Dim info As MailInfo = infos(i)

            Dim oMail As Mail = oClient.GetMail(info)
            ' Save mail to local file
            oMail.SaveAs(String.Format("c:\{0}.eml", i), True)

            ' Delete email
            oClient.Delete(info)
        Next
       
        oClient.Quit()
    Catch ep As Exception
        Console.WriteLine("Error: {0}", ep.Message)
    End Try

End Sub


[C# - Retrieve Email from Shared MailBox on Exchange Server] using System; using System.IO; using System.Globalization; using System.Text; using EAGetMail; public void RetrieveMail_from_SharedMailbox() { try { // Only Exchange WebDAV and Exchange Web Service support this feature. MailServer oServer = new MailServer("myexchangeserveraddress", "test@myexchange", "testpassword", true, ServerAuthType.AuthLogin, ServerProtocol.ExchangeEWS); // set the mailbox to accesss, // Then you will access shared@exchange mailbox instead of test@exchange oServer.Alias = "shared@exchange"; // WebDAV Example // MailServer oServer= new MailServer("myexchangeserveraddress", // "test@myexchange", "testpassword", false, // ServerAuthType.AuthLogin, ServerProtocol.ExchangeWebDAV); // Set the mailbox to accesss, please do not append domain with WebDAV protocol // Then you will access shared@exchange mailbox instead of test@exchange // oServer.Alias = "shared"; MailClient oClient = new MailClient("TryIt"); oClient.Connect(oServer); MailInfo [] infos = oClient.GetMailInfos(); for( int i = 0; i < infos.Length; i++ ) { MailInfo info = infos[i]; Mail oMail = oClient.GetMail(info); // Save mail to local file oMail.SaveAs(String.Format("c:\\{0}.eml", i), true); // Delete email oClient.Delete(info); } oClient.Quit(); } catch( Exception ep ) { Console.WriteLine("Error: {0}", ep.Message); } }
[C++/CLI - Retrieve Email from Shared MailBox on Exchange Server] using namespace System; using namespace System::Globalization; using namespace System::IO; using namespace EAGetMail; void ReceiveMail_from_SharedMailbox() { try { // Only Exchange WebDAV and Exchange Web Service support this feature. MailServer ^oServer = gcnew MailServer("myexchangeserveraddress", "test@myexchange", "testpassword", true, ServerAuthType::AuthLogin, ServerProtocol::ExchangeEWS); // Set the mailbox to accesss, // Then you will access shared@exchange mailbox instead of test@exchange oServer->Alias = "shared@exchange"; // WebDAV Example // MailServer ^oServer= gcnew MailServer("myexchangeserveraddress", // "test@myexchange", "testpassword", false, // ServerAuthType::AuthLogin, ServerProtocol::ExchangeWebDAV); // Set the mailbox to accesss, please do not append domain with WebDAV protocol // Then you will access shared@exchange mailbox instead of test@exchange // oServer->Alias = "shared"; MailClient ^oClient = gcnew MailClient("TryIt"); oClient->Connect(oServer); array<MailInfo^>^infos = oClient->GetMailInfos(); for( int i = 0; i < infos->Length; i++ ) { MailInfo ^info = infos[i]; Mail ^oMail = oClient->GetMail(info); // Save mail to local file oMail->SaveAs(String::Format("c:\\{0}.eml", i), true); // Delete mail from server oClient->Delete(info); } oClient->Quit(); } catch( Exception ^ep ) { Console::WriteLine( "Error: {0}", ep->Message); } }

See Also

User Authentication and SSL/TLS Connection
MailClient.Connect Method

Online Tutorials

Read Email and Parse Email in C# - Tutorial
Read Email and Parse Email in VB.NET - Tutorial
Read Email and Parse Email C++/CLI - Tutorial