Using EWS Managed API to create appointments for other users?

孤者浪人 提交于 2019-12-20 18:41:47

问题


In EWS Managed API is it easy to create an appointment for a specific user:

ExchangeService service = new ExchangeService();
service.Credentials = new NetworkCredentials ( "administrator", "password", "domain" );
service.AutodiscoverUrl(emailAddress);

Appointment appointment = new Appointment(service);
appointment.Subject = "Testing";
appointment.Start = DateTime.Now;
appointment.End = appointment.Start.AddHours(1);
appointment.Save();

This will create a appointment for the administrator. But say I wanted to actually create an appointment for another user (not add that user as an attendee to me appointment). It this possible via the EWS Managed API?


回答1:


Folder inboxFolder = Folder.Bind(service, new FolderId(WellKnownFolderName.Inbox, "user1@example.com"));

Will work too. Then pass inboxFolder.id to the Appointment.Save call. The updates and deletes don't need this. The best answer is to use impersonate, but this requires it to be enabled by the server admins. If you don't wield such power, this method will let you do what you need. Note: the user running your application must have permissions on the target account or this will fail (as it should).

Found here: http://msdn.microsoft.com/en-us/library/gg274408(v=EXCHG.80).aspx




回答2:


I know this has been answered but in answer to @Aamir's comment you can do this using delegates I've just done it for a project I'm working on.

As @matt suggested in his answer you can amend the save method of the appointment to point to the other users folder which in this case would be Calendar.

Code would look as below

Appointment appointment = new Appointment(service);
appointment.Subject = "Testing";
appointment.Start = DateTime.Now;
appointment.End = appointment.Start.AddHours(1);
appointment.Save(new FolderId(WellKnownFolderName.Calendar, new Mailbox(_EmailAddress)));

Hope that helps




回答3:


I figured it out from this article: http://msdn.microsoft.com/en-us/library/dd633680(EXCHG.80).aspx

You should use the service.ImpersonatedUserId attribute.



来源:https://stackoverflow.com/questions/2419651/using-ews-managed-api-to-create-appointments-for-other-users

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!