I want to delete Appointments via the EWS but it doesn't work. I have the following code:

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);
    }
}

The User that is logged in on the machine(me) is a Owner of the Calender from the user Address. But if I try to delete the Appointment the Exception is "Object cannot be deleted". The ItemId is correct. If I use the user Address as Credentials it works.

有帮助吗?

解决方案

To use DeleteMode.MoveToDeletedItems, you need write access to the DeletedItems folder in addition to your access to the Calendar folder. If you don't want to add folder perms to the Deleted Items folder, you can use either DeleteMode.HardDelete or DeleteMode.SoftDelete.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top