Guest User

Untitled

a guest
Oct 15th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. public class ExchangeFunctions
  2. {
  3. private const string _username = "uname";
  4. private const string _password = "password";
  5. private const string _domain = "domain";
  6.  
  7. public static string CreateAppointment(string mailboxId, MyAppointment appt)
  8. {
  9. var service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
  10. service.Credentials = new WebCredentials(_username, _password, _domain);
  11.  
  12. // auto loads the url for the targetted mailbox
  13. service.AutodiscoverUrl(mailboxId);
  14.  
  15. var appointment = ConvertAppointment(service, appt);
  16.  
  17. // save the appointment, bound to the targetted user's mailbox, using delegate permissions
  18. appointment.Save(new FolderId(WellKnownFolderName.Calendar, mailboxId));
  19. }
  20.  
  21. // Convert My Appointment to Exchange Appointment class
  22. private Appointment ConvertAppointment(ExchangeService service, MyAppointment appt)
  23. {
  24. // create the appointment
  25. var appointment = new Appointment(service);
  26. appointment.Subject = appt.Subject;
  27. appointment.Body = appt.Body;
  28. appointment.Start = appt.Begin;
  29. appointment.End = appt.End;
  30. appointment.LegacyFreeBusyStatus = appt.Busy ? LegacyFreeBusyStatus.Busy : LegacyFreeBusyStatus.Free;
  31.  
  32. return appointment;
  33. }
  34. }
Add Comment
Please, Sign In to add comment