MailServer.Alias Property


Gets or sets the MS Exchange Server shared mailbox.

[Visual Basic 6.0]
Public Property Get Alias() As String
Public Property Let Alias(newVal As String)
[Visual C++]
public: get_Alias(BSTR* pVal);
public: put_Alias(BSTR newVal);

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 6.0, VBScript, Visual C++] The following example demonstrates how to receive email with EAGetMail POP3 & IMAP ActiveX Object, but it doesn't demonstrates the events and mail parsing usage. To get the full samples of EAGetMail, please refer to Samples section.

[Visual Basic 6.0]
Public Sub ReceiveMail_from_Shared_Mailbox()
    
    Const MailServerPop3 = 0
    Const MailServerImap4 = 1
    Const MailServerEWS = 2
    Const MailServerDAV = 3
    Const MailServerMsGraph = 4

    'For evaluation usage, please use "TryIt" as the license code, otherwise the
    '"invalid license code" exception will be thrown. However, the object will expire in 1-2 months, then
    '"trial version expired" exception will be thrown.
    Dim oClient As New EAGetMailObjLib.MailClient
    oClient.LicenseCode = "TryIt"
    
    'Only Exchange WebDAV and Exchange Web Service support this feature.
    Dim oServer As New EAGetMailObjLib.MailServer
    oServer.Server = "myexchangeserveraddress"
    oServer.User = "test@myexchange"
    oServer.Password = "testpassword"
    oServer.SSLConnection = True 'By Default, EWS requires SSL
    oServer.Protocol = MailServerEWS

    ' 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 EAGetMailObjLib.MailServer
    ' oServer.Server = "myexchangeserveraddress"
    ' oServer.User = "test@myexchange"
    ' oServer.Password = "testpassword"
    ' oServer.SSLConnection = False ' By Default, WebDAV does not require SSL
    ' oServer.Protocol = MailServerDAV

    ' 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"
    
    
On Error GoTo ErrorHandle
    oClient.Connect oServer

    Dim infos As EAGetMailObjLib.MailInfoCollection
    Set infos = oClient.GetMailInfoList()
    
    Dim i
    For i = 0 To infos.Count - 1
        Dim info As EAGetMailObjLib.MailInfo
        Set info = infos.Item(i)

        Dim oMail As EAGetMailObjLib.Mail
        Set oMail = oClient.GetMail(info)
        'Save mail to local
        oMail.SaveAs "d:\tempfolder\" & i & ".eml", True

        ' Delete email from server
        oClient.Delete info
    Next

    '' Delete method just mark the email as deleted,
    ' Quit method expunge the emails from server permanently.
    oClient.Quit
    Exit Sub

ErrorHandle:
    ''Error handle
    MsgBox Err.Description
    
    oClient.Close
End Sub


[VBScript] Sub ReceiveMail_from_Shared_Mailbox() Const MailServerPop3 = 0 Const MailServerImap4 = 1 Const MailServerEWS = 2 Const MailServerDAV = 3 Const MailServerMsGraph = 4 'For evaluation usage, please use "TryIt" as the license code, otherwise the '"invalid license code" exception will be thrown. However, the object will expire in 1-2 months, then '"trial version expired" exception will be thrown. Dim oClient Set oClient = CreateObject("EAGetMailObj.MailClient") oClient.LicenseCode = "TryIt" 'Only Exchange WebDAV and Exchange Web Service support this feature. Dim oServer Set oServer = CreateObject("EAGetMailObj.MailServer") oServer.Server = "myexchangeserveraddress" oServer.User = "test@myexchange" oServer.Password = "testpassword" oServer.SSLConnection = True 'By Default, EWS requires SSL oServer.Protocol = MailServerEWS ' set the mailbox to accesss, ' Then you will access shared@exchange mailbox instead of test@exchange oServer.Alias = "shared@exchange" ' WebDAV Example ' Dim oServer ' Set oServer = CreateObject("EAGetMailObj.MailServer") ' oServer.Server = "myexchangeserveraddress" ' oServer.User = "test@myexchange" ' oServer.Password = "testpassword" ' oServer.SSLConnection = False ' By Default, WebDAV does not require SSL ' oServer.Protocol = MailServerDAV ' 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" oClient.Connect oServer Dim infos Set infos = oClient.GetMailInfoList() Dim i For i = 0 To infos.Count - 1 Dim info Set info = infos.Item(i) Dim oMail Set oMail = oClient.GetMail(info) 'Save mail to local oMail.SaveAs "d:\tempfolder\" & i & ".eml", True ' Delete email from server oClient.Delete info Next '' Delete method just mark the email as deleted, ' Quit method expunge the emails from server permanently. oClient.Quit End Sub
[Visual C++] #include "stdafx.h" #include <windows.h> #include "eagetmailobj.tlh" using namespace EAGetMailObjLib; void ReceiveMail_from_Shared_Mailbox() { ::CoInitialize(NULL); const int MailServerPop3 = 0; const int MailServerImap4 = 1; const int MailServerEWS = 2; const int MailServerDAV = 3; const int MailServerMsGraph = 4; try { IMailClientPtr oClient; oClient.CreateInstance(__uuidof(EAGetMailObjLib::MailClient)); // For evaluation usage, please use "TryIt" as the license code, otherwise the // "invalid license code" exception will be thrown. However, the object will expire in 1-2 months, then // "trial version expired" exception will be thrown. oClient->LicenseCode = _T("TryIt"); //Only Exchange WebDAV and Exchange Web Service support this feature-> IMailServerPtr oServer; oServer.CreateInstance(__uuidof(EAGetMailObjLib::MailServer)); oServer->Server = _T("myexchangeserveraddress"); oServer->User = _T("test@myexchange"); oServer->Password = _T("testpassword"); oServer->SSLConnection = VARIANT_TRUE; //By Default, EWS requires SSL oServer->Protocol = MailServerEWS // set the mailbox to accesss, // Then you will access shared@exchange mailbox instead of test@exchange oServer->Alias = _T("shared@exchange"); // WebDAV Example // IMailServerPtr oServer; // oServer.CreateInstance(__uuidof(EAGetMailObjLib::MailServer)); // oServer->Server = _T("myexchangeserveraddress"); // oServer->User = _T("test@myexchange"); // oServer->Password = _T("testpassword"); // oServer->SSLConnection = VARIANT_FALSE; // By Default, WebDAV does not require SSL // oServer->Protocol = MailServerDAV // 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 = _T("shared"); oClient->Connect(oServer); IMailInfoCollectionPtr infos = oClient->GetMailInfoList(); for(long i = 0; i < infos->Count; i++) { IMailInfoPtr pInfo = infos->GetItem(i); IMailPtr oMail = oClient->GetMail(pInfo); TCHAR szFile[MAX_PATH+1]; memset(szFile, 0, sizeof(szFile)); ::wsprintf(szFile, _T("d:\\tempfolder\\%d.eml"), i); //save to local disk oMail->SaveAs(szFile, VARIANT_TRUE); // delete email from server oClient->Delete(pInfo); } // Delete method just mark the email as deleted, // Quit method expunge the emails from server permanently. oClient->Quit(); } catch(_com_error &ep) { _tprintf(_T("ERROR: %s\r\n"), (TCHAR*)ep.Description()); } ::CoUninitialize(); }

See Also

User Authentication and SSL/TLS Connection
MailClient.Connect Method

Online Tutorials

Read Email and Parse Email in VB6 - Tutorial
Read Email and Parse Email in Delphi - Tutorial
Read Email and Parse Email VC++ - Tutorial