none
EWS Exception: Set action is invalid for property RRS feed

  • Question

  • I am trying to update an existing appointment but EWS is throwing "Set action is invalid for property.". If I comment RequiredAttendees property of appointment object then code is working fine except it does not send email to existing attendees.

    I will appreciate if anyone can help me to figure out why EWS throwing exception when I update RequiredAttendees of the appointment.

    Here is my code snippet:

    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
    service.Credentials = new WebCredentials("ews_calendar", PASSWORD, "acme");
    service.Url = new Uri("https://acme.com/EWS/Exchange.asmx");
    ImpersonatedUserId impUser = new ImpersonatedUserId();
    service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "tin.tin@acme.com");
    
    string itemId = "";
    DateTime PreviousStartDate = new DateTime(2012, 04, 02, 18, 00, 00);
    DateTime PreviousEndDate = new DateTime(2012, 04, 02, 18, 30, 00);
    CalendarView calView = new CalendarView(PreviousStartDate, PreviousEndDate);
    Appointment appointment = new Appointment(service);
    try
    {
        calView.PropertySet = new PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.IsRecurring, AppointmentSchema.AppointmentType);
        FindItemsResults<Appointment> findResults = service.FindAppointments(WellKnownFolderName.Calendar, calView);
    
        List<Item> items = new List<Item>();
        foreach (Appointment appt in findResults.Items)
        {
            appt.Load();
            items.Add(appt);
        }
    
        if (items.Count > 0)
        {
            service.LoadPropertiesForItems(items, PropertySet.FirstClassProperties);
            appointment = (Appointment) items[0];
            appointment.Load(new PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Start, AppointmentSchema.ReminderDueBy, AppointmentSchema.End, AppointmentSchema.StartTimeZone, AppointmentSchema.EndTimeZone, AppointmentSchema.TimeZone));
        }
    
        appointment.RequiredAttendees.Add("tin.tin@acme.com");
    
        appointment.Start = new DateTime(2012, 04, 02, 18, 00, 0);
        appointment.End = new DateTime(2012, 04, 02, 18, 30, 0);
    
        // throwing exception here -- Set action is invalid for property.
        appointment.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy);
    }
    catch (Exception ex)
    {
        //
    }

    Monday, April 2, 2012 5:38 PM