Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Create folder and set permission
The following example shows you how to create a folder and set permission.
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 { CalendarPermission permission1 = new CalendarPermission(); permission1.UserId = new UserId("Mark@mydomain.com"); permission1.Level = CalendarPermissionLevel.Author; CalendarFolder calFolder = new CalendarFolder("TestCalendar"); calFolder.PermissionSet = new CalendarPermissionSet(); calFolder.PermissionSet.Permissions.Add(permission1); FolderId folder1Id = service.CreateFolder(calFolder, StandardFolder.Calendar); } 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 permission1 As New CalendarPermission() permission1.UserId = New UserId("Mark@mydomain.com") permission1.Level = CalendarPermissionLevel.Author Dim calFolder As New CalendarFolder("TestCalendar") calFolder.PermissionSet = New CalendarPermissionSet() calFolder.PermissionSet.Permissions.Add(permission1) Dim folder1Id As FolderId = service.CreateFolder(calFolder, StandardFolder.Calendar) 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*