EWSを使用してOutlook予定表に予定を作成します。私はhttps://msdn.microsoft.com/en-us/library/office/dn722379(v=exchg.150).aspxリンクに続いた。しかし、私はこのエラーを見ています:他のユーザーの予定カレンダーに予定を保存している間、アカウントに要求されたユーザーを偽装する権限がありません
"The account does not have permission to impersonate the requested user".
私のコードを
private static ExchangeService Service
{
get
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
//service.Credentials = new WebCredentials("[email protected]", password);
service.AutodiscoverUrl("[email protected]");
return service;
}
}
private void SaveAppointment()
{
IAppointmentFactory iappointment = new AppointmentFactory();
List<string> lstEmail = new List<string>() {"[email protected]"};
CreateAppointments(Service, lstEmail, iappointment);
}
private static void CreateAppointments(ExchangeService service, List<string> emailAddresses, IAppointmentFactory factory)
{
// Loop through the list of email addresses to add the appointment.
foreach (var emailAddress in emailAddresses)
{
Console.WriteLine(string.Format(" Placing appointment in calendar for {0}.", emailAddress));
// Set the email address of the account to get the appointment.
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, emailAddress);
// Get the appointment to add.
Microsoft.Exchange.WebServices.Data.Appointment appointment = factory.GetAppointment(service);
// Save the appointment.
try
{
if (appointment.RequiredAttendees.Count > 0)
{
// The appointment has attendees so send them the meeting request.
appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);
}
else
{
// The appointment does not have attendees, so just save to calendar.
appointment.Save(SendInvitationsMode.SendToNone);
}
}
catch (ServiceResponseException ex)
{
Console.WriteLine(string.Format("Could not create appointment for {0}", emailAddress));
Console.WriteLine(ex.Message);
}
}
}
を、あなたはこの問題をグーグルしてから最初の結果を選択しましたか? http://stackoverflow.com/questions/15204411/the-account-does-not-have-permission-to-impersonate-the-requested-user – Bassie
はい、私はすでにこのリンクに行きましたが、理解できませんでした。そのコードを自分のコードに修正してください。あなたはお勧めできますか? – manika