Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating appointment on Exchange server calendar as other user without impersonation (EWS)

I am creating simple app for appointments scheduling and I want to implement ability for me to create appointments for my users.

I managed to create,update and delete my calendar on Exchange Server, and I somewhat managed to create appointments adding my colleagues as RequiredAttendees like so:

//service variable is being created using my credidentals
Appointment meeting = new Appointment(service);
meeting.Subject = "Some subject ";
meeting.Body = "Some body.";
meeting.Start = DateTime.Now;
meeting.End = meeting.Start.AddHours(4);
meeting.Location = "Some Location";
meeting.RequiredAttendees.Add("[email protected]");

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

But it is just setting him as required attendee. Next thing is I tried using impersonation, but I can't access hosting server to set myself as master and others to have to share calendar with me (due to permissions and stuff) so I had to scrape that as well. Also, he set me up to be his publishing author on his calendar. Is there something I am missing, or can't seem to find on MSDN sites?

EDIT: I am able to create appointment in his calendar in outlok.

like image 907
Kadaj Avatar asked Jun 29 '16 08:06

Kadaj


1 Answers

If anyone comes across same issues as I did in here please follow these steps:

  1. Make sure that person for which you are creating appointment sets you up (on exchange server or in outlok as "Editing author" with all permissions.

  2. After that you can create appointments for him (verify this by going to your outlok and creating some test appointments).

This code works for me:

Folder inboxFolder = Folder.Bind(service, new FolderId(WellKnownFolderName.Calendar, "[email protected]"));
Appointment appointmentOther = new Appointment(service);
appointmentOther.Subject = "Test 2";
appointmentOther.Body = "Body text";
appointmentOther.Start = DateTime.Now;
appointmentOther.End = DateTime.Today.AddHours(16);
appointmentOther.Location = "My Office";
appointmentOther.IsReminderSet = true;
appointmentOther.ReminderMinutesBeforeStart = 30;
appointmentOther.Save(inboxFolder.Id,SendInvitationsMode.SendToNone);

Good luck :)

like image 138
Kadaj Avatar answered Sep 30 '22 12:09

Kadaj