none
[Exchange-Online][EWS][c#][Windows 8.1] When creating appointment using impersonation "Set action is invalid for property" error occurs. RRS feed

  • Question

  • I have an Outlook add-in that creates appointments to a load of Office 365 calendars. It used to work well but suddenly I have hit a problem.

    The basic calling code is

    Appointment appointment = new Appointment(exchangeService);
       appointment.Subject = subject;
       appointment.Body = body;
       appointment.Location = location;
       appointment.IsAllDayEvent = allDay;
       appointment.LegacyFreeBusyStatus = LegacyFreeBusyStatus.Busy;
       appointment.IsOnlineMeeting = false;
       appointment.Save(SendInvitationsMode.SendToNone);

    This still works fine on my own Office 365 mailbox but if I switch to another, using Impersonation, the Save line now throws the error "Set action is invalid for property."

    There does not seem to be a problem with impersonation. The line

    exchangeService.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, selectedUserEmail);

    runs OK and afterwards the exchangeService's ImpersonatedUserID gives the correct email address.

    If I look at the appointment object in the Watch window immediately after the line that creates it has run I can see that most of the properties have an entry like:

    appointment.AdjacentMeetingCount' threw an exception of type 'Microsoft.Exchange.WebServices.Data.ServiceObjectPropertyException'.

    Also, several properties including Subject are not listed in the expanded appointment object in the Watch window.

    However, entering appointments.Subject explicitly in the Watch window does give the correct result.

    I have used the floating watch to check the value of each property straight after it is set and each one is as expected.

    I am at a loss as to what to check next and would be grateful for all ideas.


    Mike VE

    Friday, March 27, 2015 6:15 PM

All replies

  • I would try commenting out each property that you set to find out which one is causing the error. Another thing you could try is enabling tracing and looking at the server response.
    Monday, March 30, 2015 2:38 PM
    Moderator
  • Thanks for the reply Jason. I did as you suggested and found that it was the IsOnlineMeeting that caused the problem. Once that was commented out everything worked as expected. On checking I see that this property is ReadOnly for everyone except the organizer of the meeting. Clearly the Impersonate role is not regarded as the organiser.

    I don't think it is going to matter so long as the user in whose calendar the appointment is created has fully access to the appointment, which seems to be the case.

    Thanks for your help.


    Mike VE

    Thursday, April 2, 2015 8:04 AM