Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Get delegate
The following example shows you how to get delegated users.
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); try { Mailbox mailbox = new Mailbox("John@mydomain.com"); DelegateResponse response = service.GetDelegate(mailbox, true); IList
delegateUserResponse = response.DelegateUserResponses; for (int i = 0; i < delegateUserResponse.Count; i++) { DelegateUser user = delegateUserResponse[i].DelegateUser; Console.WriteLine("User = " + user.UserId); Console.WriteLine("CalendarFolderPermissionLevel = " + user.CalendarFolderPermissionLevel); Console.WriteLine("ContactsFolderPermissionLevel = " + user.ContactsFolderPermissionLevel); Console.WriteLine("InboxFolderPermissionLevel = " + user.InboxFolderPermissionLevel); Console.WriteLine("JournalFolderPermissionLevel = " + user.JournalFolderPermissionLevel); Console.WriteLine("NotesFolderPermissionLevel = " + user.NotesFolderPermissionLevel); Console.WriteLine("ReceiveCopiesOfMeetingMessages = " + user.ReceiveCopiesOfMeetingMessages); Console.WriteLine("TasksFolderPermissionLevel = " + user.TasksFolderPermissionLevel); Console.WriteLine("ViewPrivateItems = " + user.ViewPrivateItems); 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.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 mailbox As New Mailbox("John@mydomain.com") Dim response As DelegateResponse = service.GetDelegate(mailbox, True) Dim delegateUserResponse As IList(Of DelegateUserResponse) = response.DelegateUserResponses For i As Integer = 0 To delegateUserResponse.Count - 1 Dim user As DelegateUser = delegateUserResponse(i).DelegateUser Console.WriteLine("User = " & user.UserId.DisplayName) Console.WriteLine("CalendarFolderPermissionLevel = " & user.CalendarFolderPermissionLevel.ToString()) Console.WriteLine("ContactsFolderPermissionLevel = " & user.ContactsFolderPermissionLevel.ToString()) Console.WriteLine("InboxFolderPermissionLevel = " & user.InboxFolderPermissionLevel.ToString()) Console.WriteLine("JournalFolderPermissionLevel = " & user.JournalFolderPermissionLevel.ToString()) Console.WriteLine("NotesFolderPermissionLevel = " & user.NotesFolderPermissionLevel.ToString()) Console.WriteLine("ReceiveCopiesOfMeetingMessages = " & user.ReceiveCopiesOfMeetingMessages.ToString()) Console.WriteLine("TasksFolderPermissionLevel = " & user.TasksFolderPermissionLevel.ToString()) Console.WriteLine("ViewPrivateItems = " & user.ViewPrivateItems.ToString()) 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*