I have a set up where I need to add a
delegate to various user calendars programmatically. Using a sample from MDSN, I've gotten as far as trying to add the
delegate, but after the call to the service binding, I get nothing back...no success or fail....nothing.
How I create the service binidng:
// Initialize the service binding
serviceBinding = new ExchangeServiceBinding();
serviceBinding.Credentials = new NetworkCredential(Properties.Settings.Default.UserName, Properties.Settings.Default.Password, Properties.Settings.Default.Domain);
// A production application should call the autodiscover service to locate the service binding url
serviceBinding.Url = Properties.Settings.Default.EWSUrlEndPoint;
serviceBinding.RequestServerVersionValue = new RequestServerVersion();
serviceBinding.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2007_SP1;
serviceBinding.AllowAutoRedirect = true;
and the
delegate addition:
static void AddDelegate(string email)
{
// Create the request.
AddDelegateType request = new AddDelegateType();
// Identify the agent's mailbox.
request.Mailbox = new EmailAddressType();
request.Mailbox.EmailAddress = email;
// add the exch_integration user as a
delegate
request.DelegateUsers = new DelegateUserType[1];
request.DelegateUsers[0] = new DelegateUserType();
request.DelegateUsers[0].UserId = new UserIdType();
request.DelegateUsers[0].UserId.PrimarySmtpAddress = "
[email protected]";
// Specify the permissions that are granted to exch_integration
request.DelegateUsers[0].DelegatePermissions = new DelegatePermissionsType();
request.DelegateUsers[0].DelegatePermissions.CalendarFolderPermissionLevel = DelegateFolderPermissionLevelType.Author;
request.DelegateUsers[0].DelegatePermissions.CalendarFolderPermissionLevelSpecified = true;
// Specify whether the agent recieves meeting requests.
request.DeliverMeetingRequests = DeliverMeetingRequestsType.DelegatesAndSendInformationToMe;
request.DeliverMeetingRequestsSpecified = true;
try
{
// Send the request
and get the response.
AddDelegateResponseMessageType response = serviceBinding.AddDelegate(request);
DelegateUserResponseMessageType[] responseMessages = response.ResponseMessages;
// One DelegateUserResponseMessageType exists for each attempt to add a
delegate user to an account.
foreach (DelegateUserResponseMessageType user in responseMessages)
{
Console.WriteLine("Results of adding user: " + user.ResponseClass.ToString());
Console.WriteLine(user.DelegateUser.UserId.DisplayName);
Console.WriteLine(user.DelegateUser.UserId.PrimarySmtpAddress);
Console.WriteLine(user.DelegateUser.UserId.SID);
}
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
}
The response nothing which must mean that the AddDelegate call isn't hitting the server properly, but I'm not sure. Thanks.