Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# EWS Delete Appointment doesn't work

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("[email protected]", 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.

like image 526
BluePalmTree Avatar asked Feb 13 '23 02:02

BluePalmTree


1 Answers

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.

like image 67
Mimi Gentz Avatar answered Feb 16 '23 03:02

Mimi Gentz