AutodiscoverService.GetUserSettings method

Retrieves the specified user settings for an SMTP address.

Namespace:  Microsoft.Exchange.WebServices.Autodiscover
Assembly:  Microsoft.Exchange.WebServices (in Microsoft.Exchange.WebServices.dll)

public GetUserSettingsResponse GetUserSettings(
	string userSmtpAddress,
	params UserSettingName[] userSettingNames


Type: System.String

The SMTP address of the user.

Type: []

The user setting names.

Return value

Type: Microsoft.Exchange.WebServices.Autodiscover.GetUserSettingsResponse
The requested settings for the specified user.

The GetUserSettings method does not follow address and URL redirections. Only the requested user settings are retrieved, if they exist.

The following code example shows how to use the GetUserSettings method to retrieve the UserDisplayName, CasVersion, and other user settings requested in the userSettingNames parameter. The user setting name and value are displayed.

public static GetUserSettingsResponse GetUserSettings(
     AutodiscoverService service,
     string emailAddress,
     int maxHops,
     params UserSettingName[] settings)
        Uri url = null;
        GetUserSettingsResponse response = null;

        for (int attempt = 0; attempt < maxHops; attempt++)
             service.Url = url;
             service.EnableScpLookup = (attempt < 2);

             response = service.GetUserSettings(emailAddress, settings);

             if (response.ErrorCode == AutodiscoverErrorCode.RedirectAddress)
                 url = new Uri(response.RedirectTarget);
             else if (response.ErrorCode == AutodiscoverErrorCode.RedirectUrl)
                url = new Uri(response.RedirectTarget);
                 return response;

         throw new Exception("No suitable Autodiscover endpoint was found.");