Using EWS Managed API to create appointments for other users?
Asked Answered
C

3

13

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?

Comprehensive answered 10/3, 2010 at 18:53 Comment(3)
@Alfred. Can you tell me where the bloody hell the Managed API DLL installed. I cant find it anywhere on my machine....Many Thanks.Zamarripa
@brumScouse. Instead of a comment you should post a new question. Anyway, the Managed API DLL is not installed with Exchange Server. You have to download it from Microsoft and install on your computer. As of this date, the most current version can be found at microsoft.com/downloads/en/…Judy
@Zamarripa after following Alfred's instructions the DLL will be found at a location similar to this: C:\Program Files\Microsoft\Exchange\Web Services\2.2Vigilantism
C
7

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.

Comprehensive answered 10/3, 2010 at 19:41 Comment(1)
Any chance this can be done using delegation. I know that we can create and manage delegate using EWS API, but don't know if there is the way to use delegation to create appointments etc.Heyer
P
9
Folder inboxFolder = Folder.Bind(service, new FolderId(WellKnownFolderName.Inbox, "[email protected]"));

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

Phosphoprotein answered 18/10, 2011 at 2:39 Comment(1)
thanks! That works, but it must be WellKnownFolderName.Calendar instead of WellKnownFolderName.Inbox.Galacto
P
9

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

Present answered 11/2, 2014 at 16:29 Comment(0)
C
7

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.

Comprehensive answered 10/3, 2010 at 19:41 Comment(1)
Any chance this can be done using delegation. I know that we can create and manage delegate using EWS API, but don't know if there is the way to use delegation to create appointments etc.Heyer

© 2022 - 2024 — McMap. All rights reserved.