Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Get user configuration
The following example shows you how to get user configuration.
C# example
using System; using System.Net; using Independentsoft.Exchange; namespace Sample { class Program { static void Main(string[] args) { NetworkCredential credential = new NetworkCredential("username", "password"); Service service = new Service("https://myserver/ews/Exchange.asmx", credential); try { UserConfigurationName configName = new UserConfigurationName("CategoryList", new StandardFolderId(StandardFolder.Calendar)); GetUserConfigurationResponse response = service.GetUserConfiguration(configName, UserConfigurationProperty.All); if (response.UserConfiguration != null && response.UserConfiguration.XmlData != null) { byte[] xmlDataBuffer = Convert.FromBase64String(response.UserConfiguration.XmlData); string xmlData = System.Text.Encoding.UTF8.GetString(xmlDataBuffer); Console.WriteLine(xmlData); } Console.Read(); } catch (ServiceRequestException ex) { Console.WriteLine("Error: " + ex.Message); Console.WriteLine("Error: " + ex.XmlMessage); Console.Read(); } catch (WebException ex) { Console.WriteLine("Error: " + ex.Message); Console.Read(); } } } }
VB example
Imports System Imports System.Net Imports Independentsoft.Exchange Namespace Sample Class Module1 Shared Sub Main(ByVal args As String()) Dim credential As New NetworkCredential("username", "password") Dim service As New Service("https://myserver/ews/Exchange.asmx", credential) Try Dim configName As New UserConfigurationName("CategoryList", New StandardFolderId(StandardFolder.Calendar)) Dim response As GetUserConfigurationResponse = service.GetUserConfiguration(configName, UserConfigurationProperty.All) If response.UserConfiguration IsNot Nothing AndAlso response.UserConfiguration.XmlData IsNot Nothing Then Dim xmlDataBuffer As Byte() = Convert.FromBase64String(response.UserConfiguration.XmlData) Dim xmlData As String = System.Text.Encoding.UTF8.GetString(xmlDataBuffer) Console.WriteLine(xmlData) End If Console.Read() Catch ex As ServiceRequestException Console.WriteLine("Error: " + ex.Message) Console.WriteLine("Error: " + ex.XmlMessage) Console.Read() Catch ex As WebException Console.WriteLine("Error: " + ex.Message) Console.Read() End Try End Sub End Class End Namespace
Need help? Ask our developers:
Name*
Email*
Message*