Jack Wang
Jack Wang

Reputation: 97

Exchange web service set organizer of the appointment

When I use Service account to add a new appointment, the organizer always the user of Credentials to Exchange service, I want to set the organizer to another user, but the organizer property is readonly, how can I achieve that?

           var appointment = new Appointment(_service.ExchangeService);
            
            if (exchangeAppointment.Participants.Any() && exchangeAppointment.Participants != null)
            {
                foreach (var participant in exchangeAppointment.Participants)
                {
                    appointment.RequiredAttendees.Add(participant);
                }
            }
            appointment.Resources.Add(exchangeAppointment.RoomAdIdentityEmail);
            appointment.Location = string.Join(",", appointment.Resources);
            appointment.Subject = exchangeAppointment.Subject;
            appointment.Body = exchangeAppointment.Body;
            appointment.Start = exchangeAppointment.StartTime;
            appointment.End = exchangeAppointment.EndTime;
            appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);

Upvotes: 3

Views: 3332

Answers (1)

Glen Scales
Glen Scales

Reputation: 22032

The Organizer is going to be set based on the Calendar your saving the Appointment to, when you using a Service Account your creating the Appointment OnBehalf of the Organizer so you would need set the Save location to the calendar of the Organizer you want eg

Save(new FolderId(WellKnownFolderName.Calendar, "[email protected]"), SendInvitationsMode.SendToAllAndSaveCopy);

The other option is to use EWS Impersonation and then Impersonate the Organizer http://msdn.microsoft.com/en-us/library/office/dd633680%28v=exchg.80%29.aspx

Cheers Glen

Upvotes: 5

Related Questions