Access to a appoitment from the Exchange calendar in c#

To use this code, you need to installhttp://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=c3342fb3-fbcc-4127-becf-872c746840e1 , this will create a dll, that you need to import to the project

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);

 service.Credentials = new NetworkCredential(user, password, domain);

 service.Url = new Uri("https:/domain/EWS/Exchange.asmx");

 Mailbox mb = new Mailbox(email_to_access);

 DateTime startDate = new DateTime(2010, 1, 1);
 DateTime endDate = new DateTime(2011, 1, 31);
 CalendarView calView = new CalendarView(startDate, endDate);
 calView.PropertySet = new PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.IsRecurring, AppointmentSchema.AppointmentType);

 FindItemsResults <Appointment> findResults = service.FindAppointments(WellKnownFolderName.Calendar, calView);

 foreach (Appointment appt in findResults.Items)
 {
  if (appt.AppointmentType == AppointmentType.Occurrence)
  {
  // Calendar item is an occurrence in a recurring series.
  }
  else if (appt.AppointmentType == AppointmentType.Exception)
  {
  // Calendar item is an exception in a recurring series.
  }
 }
 

0 comentários:

Enviar um comentário