I like to get an overview of someone else calendar. When I use the method 1 I can get his calendar info except the 'Occurences' items are not in...
With method 2, I'm able to get the occurences items of that person, but it shows MY Calendar items instead of that person, while I pass in the service of that persons email address...
In both way I'm passing the " service " parameter which contains otherones email address...
I need all calendar info of the X person + the occurence... Why is method 2 giving my calendar items instead of that person ?
Any advice?...
Method 1: method-> Folder.Bind is used
string username ="[email protected]"
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.UseDefaultCredentials = true;
folderIdFromCalendar = new FolderId(WellKnownFolderName.Calendar, username);
PropertySet propertySet = new PropertySet(AppointmentSchema.Subject);
Folder TargetFolder = Folder.Bind(service, folderIdFromCalendar, propertySet);
MEthod 2: method -> FindAppointments is used.
service.AutodiscoverUrl(username, RedirectionUrlValidationCallback);
/////////
DateTime startDate = DateTime.Now;
DateTime endDate = startDate.AddDays(30);
const int NUM_APPTS = 5;
// Initialize the calendar folder object with only the folder ID.
CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());
// Set the start and end time and number of appointments to retrieve.
CalendarView ccView = new CalendarView(startDate, endDate, NUM_APPTS);
// Limit the properties returned to the appointment's subject, start time, and end time.
ccView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);
// Retrieve a collection of appointments by using the calendar view.
FindItemsResults<Appointment> appointments2 = calendar.FindAppointments(ccView);
Console.WriteLine("\nThe first " + NUM_APPTS + " appointments on your calendar from " + startDate.Date.ToShortDateString() +
" to " + endDate.Date.ToShortDateString() + " are: \n");
foreach (Appointment a in appointments2)
{
Console.Write("Subject: " + a.Subject.ToString() + " ");
Console.Write("Start: " + a.Start.ToString() + " ");
Console.Write("End: " + a.End.ToString());
Console.WriteLine();
}
Method 2 should work but you need to use the FolderId's overload to specify the Mailbox to access so change
CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());
to
folderIdFromCalendar = new FolderId(WellKnownFolderName.Calendar, username);
CalendarFolder calendar = CalendarFolder.Bind(service, folderIdFromCalendar , new PropertySet());