Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Create user configuration
The following example shows you how to create 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 { UserConfigurationDictionaryKey key1 = new UserConfigurationDictionaryKey(UserConfigurationDictionaryObjectType.String, "key1"); UserConfigurationDictionaryValue value1 = new UserConfigurationDictionaryValue(UserConfigurationDictionaryObjectType.String, "value1"); UserConfigurationDictionaryKey key2 = new UserConfigurationDictionaryKey(UserConfigurationDictionaryObjectType.String, "key2"); UserConfigurationDictionaryValue value2 = new UserConfigurationDictionaryValue(UserConfigurationDictionaryObjectType.String, "value2"); UserConfigurationDictionaryEntry entry1 = new UserConfigurationDictionaryEntry(key1, value1); UserConfigurationDictionaryEntry entry2 = new UserConfigurationDictionaryEntry(key2, value2); UserConfiguration userConfiguration = new UserConfiguration(); userConfiguration.Name = new UserConfigurationName("config1", new StandardFolderId(StandardFolder.Drafts)); userConfiguration.Entries.Add(entry1); userConfiguration.Entries.Add(entry2); Response response = service.CreateUserConfiguration(userConfiguration); } 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 key1 As New UserConfigurationDictionaryKey(UserConfigurationDictionaryObjectType.[String], "key1") Dim value1 As New UserConfigurationDictionaryValue(UserConfigurationDictionaryObjectType.[String], "value1") Dim key2 As New UserConfigurationDictionaryKey(UserConfigurationDictionaryObjectType.[String], "key2") Dim value2 As New UserConfigurationDictionaryValue(UserConfigurationDictionaryObjectType.[String], "value2") Dim entry1 As New UserConfigurationDictionaryEntry(key1, value1) Dim entry2 As New UserConfigurationDictionaryEntry(key2, value2) Dim userConfiguration As New UserConfiguration() userConfiguration.Name = New UserConfigurationName("config1", New StandardFolderId(StandardFolder.Drafts)) userConfiguration.Entries.Add(entry1) userConfiguration.Entries.Add(entry2) Dim response As Response = service.CreateUserConfiguration(userConfiguration) 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*