Share via


HostedEmailManager.GetAccount Method (String)

 

Synchronous call to retrieve a new email account and to bind the new account to a Windows Server 2012 Essentials user.

Namespace:   Microsoft.WindowsServerSolutions.HostedEmail
Assembly:  Wssg.HostedEmailObjectModel (in Wssg.HostedEmailObjectModel.dll)

Syntax

public EmailAccountInfo GetAccount(
    string wssUserName
)
public:
EmailAccountInfo^ GetAccount(
    String^ wssUserName
)
Public Function GetAccount (
    wssUserName As String
) As EmailAccountInfo

Parameters

  • wssUserName
    Type: System.String

    Name of the Windows Server user to bind the email account to.

Return Value

Type: Microsoft.WindowsServerSolutions.HostedEmail.EmailAccountInfo

A EmailAccountInfo describing the new account associated with the specified user.

Examples

The following code uses GetAccount to retrieve email account information. For the complete code sample, see Quickstart: Creating a Hosted Email Adapter.

private void LoadEmailAccountInfo(string wssUserName)
{
    HostedEmailManager manager = new HostedEmailManager(Constants.AdaptorId);
    if (!manager.Connect())
    {
        throw new InvalidOperationException("HostedEmailManager connection failed");
    }
    var info = manager.GetAccount(wssUserName);

    if (info == null || info.ExtendedProperties == null || !info.ExtendedProperties.ContainsKey(Constants.ExtendedParam_DGs))
    {
        throw new InvalidOperationException("Cannot load distribution groups that the user belongs to");
    }
    accountId = info.AccountId;
    userDGs = info.ExtendedProperties[Constants.ExtendedParam_DGs].Split(Constants.ExtendedParam_DGs_Delimiter);
}

See Also

HostedEmailManager Class
Microsoft.WindowsServerSolutions.HostedEmail Namespace

Return to top