views:

264

answers:

1

The target is someone's Exchange Calendar (2007). I want to add a simple "Appointment Occurance" to someone's calendar. This code works (I am using the Microsoft.Exchange.WebServices.dll):

service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Credentials = new NetworkCredential("supervisor", "password", "DOMAIN.COM");
service.AutodiscoverUrl("<[email protected]>", ValidateRedirectionUrlCallback);
appt = new Appointment(service);
appt.Subject = "<subject>";
appt.Body = "<Body Text>";
appt.Start = _DateFrom;
appt.End = _DateTo;
appt.Sensitivity = Sensitivity.Private;
appt.Save(WellKnownFolderName.Calendar);

However, there are problems with this code:

  1. The appointment target is the employee. When adding the appointment, the appointment shows up for the employee (yay!) but also for the supervisor (boo!). Am I supposed to use the employee's credentials? If so, what if I do not have access to that - only the supervisors, am I out of the game already?
  2. The appointment shows up in Outlook as a "Meeting Appointment" and not and "Appointment Occurrence". So, the box to input meeting attendees is showing (with no one in it of course), and is irrelevant in my scenario.
  3. appt.Body does not respond at all to Environment.NewLine or "\r\n" - I haven't tried HTML yet.
A: 

Instead of WellKnownFolderName.Calendar

You should use new FolderId(WellKnownFolderName.Calendar,"[email protected]")

So the last line becomes appt.Save(new FolderId(WellKnownFolderName.Calendar,"[email protected]"));

Also having problems with the newline, this is only since version 1.1 so it probebly is a bug

Stephan