Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Get retention settings
The following example shows you how to get retention policy settings.
C# example
using System; using System.Net; using System.Collections.Generic; 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); service.RequestServerVersion = RequestServerVersion.Exchange2010SP1; try { RetentionSettings settings = service.GetRetentionSettings(StandardFolder.Inbox); foreach (RetentionPolicyTag tag in settings.RetentionPolicyTags) { Console.WriteLine(tag.Id); Console.WriteLine(tag.DisplayName); Console.WriteLine(tag.RetentionAction); Console.WriteLine(tag.Period); Console.WriteLine(tag.IsArchive); Console.WriteLine(tag.IsVisible); Console.WriteLine("---------------------------------------------"); } 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.IO 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) service.RequestServerVersion = RequestServerVersion.Exchange2010SP1 Try Dim settings As RetentionSettings = service.GetRetentionSettings(StandardFolder.Inbox) For Each tag As RetentionPolicyTag In settings.RetentionPolicyTags Console.WriteLine(tag.Id) Console.WriteLine(tag.DisplayName) Console.WriteLine(tag.RetentionAction.ToString()) Console.WriteLine(tag.Period) Console.WriteLine(tag.IsArchive) Console.WriteLine(tag.IsVisible) Console.WriteLine("---------------------------------------------") Next 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*