AddDelegateType Class
The AddDelegateType class represents a request to add delegates to a mailbox.
Namespace: ExchangeWebServices
Assembly: EWS (in ews.dll)
Syntax
'Declaration
<SerializableAttribute> _
<DesignerCategoryAttribute("code")> _
<XmlTypeAttribute(Namespace:="https://schemas.microsoft.com/exchange/services/2006/messages")> _
<GeneratedCodeAttribute("wsdl", "2.0.50727.42")> _
<DebuggerStepThroughAttribute> _
Public Class AddDelegateType
Inherits BaseDelegateType
[SerializableAttribute]
[DesignerCategoryAttribute("code")]
[XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/messages")]
[GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[DebuggerStepThroughAttribute]
public class AddDelegateType : BaseDelegateType
[SerializableAttribute]
[DesignerCategoryAttribute(L"code")]
[XmlTypeAttribute(Namespace=L"https://schemas.microsoft.com/exchange/services/2006/messages")]
[GeneratedCodeAttribute(L"wsdl", L"2.0.50727.42")]
[DebuggerStepThroughAttribute]
public ref class AddDelegateType : public BaseDelegateType
/** @attribute SerializableAttribute() */
/** @attribute DesignerCategoryAttribute("code") */
/** @attribute XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/messages") */
/** @attribute GeneratedCodeAttribute("wsdl", "2.0.50727.42") */
/** @attribute DebuggerStepThroughAttribute() */
public class AddDelegateType extends BaseDelegateType
SerializableAttribute
DesignerCategoryAttribute("code")
XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/messages")
GeneratedCodeAttribute("wsdl", "2.0.50727.42")
DebuggerStepThroughAttribute
public class AddDelegateType extends BaseDelegateType
Inheritance Hierarchy
System.Object
ExchangeWebServices.BaseRequestType
ExchangeWebServices.BaseDelegateType
ExchangeWebServices.AddDelegateType
Example
The following example shows you how to give user2 delegate permissions on folders that are owned by user1. User2 is given Author-level permissions to user1's Calendar folder and Reviewer-level permissions to user1's Contacts folder. User2 will receive copies of meeting messages and will be able to view private items in user1's mailbox. Meeting requests will be sent to both user1 and user2.
static void AddDelegate()
{
// Set the version, credentials, and the Client Access server on ExchangeServiceBinding.
ExchangeServiceBinding esb = new ExchangeServiceBinding();
esb.RequestServerVersionValue = new RequestServerVersion();
esb.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2007_SP1;
esb.Credentials = new NetworkCredential("username", "password", "domain");
esb.Url = "https://FQDN/ews/exchange.asmx";
// Create the request.
AddDelegateType request = new AddDelegateType();
// Identify the mailbox to which a delegate user will be added.
request.Mailbox = new EmailAddressType();
request.Mailbox.EmailAddress = "user1@example.com";
// Identify the delegate user and set delegate permissions.
request.DelegateUsers = new DelegateUserType[] { new DelegateUserType() };
request.DelegateUsers[0].UserId = new UserIdType();
request.DelegateUsers[0].UserId.PrimarySmtpAddress = "user2@example.com";
request.DelegateUsers[0].DelegatePermissions = new DelegatePermissionsType();
request.DelegateUsers[0].DelegatePermissions.CalendarFolderPermissionLevel = DelegateFolderPermissionLevelType.Author;
request.DelegateUsers[0].DelegatePermissions.CalendarFolderPermissionLevelSpecified = true;
request.DelegateUsers[0].DelegatePermissions.ContactsFolderPermissionLevel = DelegateFolderPermissionLevelType.Reviewer;
request.DelegateUsers[0].DelegatePermissions.ContactsFolderPermissionLevelSpecified = true;
request.DelegateUsers[0].ReceiveCopiesOfMeetingMessages = true;
request.DelegateUsers[0].ReceiveCopiesOfMeetingMessagesSpecified = true;
request.DelegateUsers[0].ViewPrivateItems = true;
request.DelegateUsers[0].ViewPrivateItemsSpecified = true;
// Identify how meeting requests are handled.
request.DeliverMeetingRequests = new DeliverMeetingRequestsType();
request.DeliverMeetingRequests = DeliverMeetingRequestsType.DelegatesAndMe;
request.DeliverMeetingRequestsSpecified = true;
try
{
// Send the AddDelegate request and get the response.
AddDelegateResponseMessageType response = esb.AddDelegate(request);
DelegateUserResponseMessageType[] durmt = new DelegateUserResponseMessageType[] { };
durmt = response.ResponseMessages;
// Check each response message.
foreach (DelegateUserResponseMessageType resp in durmt)
{
if (resp.ResponseClass == ResponseClassType.Success)
{
Console.WriteLine("Delegate user added: " + resp.DelegateUser.UserId.DisplayName);
}
else if (resp.ResponseClass == ResponseClassType.Error)
{
Console.WriteLine("Error: " + resp.MessageText);
}
else
Console.WriteLine("Warning: " + resp.MessageText);
}
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms
Development Platforms
Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003,
Target Platforms
Windows 98, Windows 2000, Windows 2000 Server, Windows CE, Windows Longhorn, Windows 98 Second Edition, Pocket PC, Smart Phone, Windows Server 2003, Windows XP Professional with Service Pack 2 (SP2)
See Also