c# EWS Delete Appointment不起作用
本文关键字:不起作用 Appointment Delete EWS | 更新日期: 2023-09-27 18:01:25
我想通过EWS
删除Appointments
,但它不起作用。我有以下代码:
private void deleteAppointment(object obj)
{
ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.Credentials = new WebCredentials(CredentialCache.DefaultNetworkCredentials);
service.AutodiscoverUrl("user@place.com", RedirectionUrlValidationCallback);
ItemId ii = (ItemId)obj;
Appointment a = Appointment.Bind(service, ii);
try
{
a.Delete(DeleteMode.MoveToDeletedItems);
}
catch (ServiceResponseException ex)
{
MessageBox.Show(ex.Message);
}
}
登录到机器(me)上的用户是来自user
地址的日历的所有者。但是,如果我试图删除Appointment
, Exception
是"对象不能被删除"。ItemId
是正确的。如果我使用user
地址作为Credentials
,它可以工作。
使用DeleteMode。MoveToDeletedItems,除了对Calendar文件夹的访问权限外,还需要对DeletedItems文件夹进行写访问。如果不想将文件夹烫发添加到已删除项文件夹,则可以使用DeleteMode。