I am trying to get the required attendees of a meeting which I got using the exchange web service. Any ideas? I think I need to use CalendarItemType, but I'm not sure how to implement it. Here is my code so far:
foreach (var wrk in Workers)
{
TimeWindow timeWindow = new TimeWindow(startDate, endDate);
AvailabilityData requestedData = AvailabilityData.FreeBusy;
List<AttendeeInfo> attendees = new List<AttendeeInfo>();
attendees.Add(new AttendeeInfo(wrk.EmailAddress));
GetUserAvailabilityResults ares = service.GetUserAvailability(attendees, timeWindow, requestedData);
foreach (AttendeeAvailability av in ares.AttendeesAvailability)
{
foreach (CalendarEvent ev in av.CalendarEvents)
{
//get info from each calendarevent
//Possibly use CalendarItemType here?
}
}
开发者_如何学Go }
Where Workers is a class I made with a list of names and corresponding email addresses.
You can retrieve the required attendees by binding to the appointment using Appointment.Bind
:
foreach (CalendarEvent ev in av.CalendarEvents)
{
var appointment = Appointment.Bind(service, new ItemId(ev.Details.StoreId));
foreach (var requiredAttendee in appointment.RequiredAttendees)
{
Console.WriteLine(requiredAttendee.Address);
}
}
You may have to convert CalendarEvent.Details.StoreId
to a different format before calling Appointment.Bind
(I am not sure about this), so if the above code is not working you may try adding a call to ExchangeService.ConvertId
:
foreach (CalendarEvent ev in av.CalendarEvents)
{
var convertedId = (AlternateId) service.ConvertId(new AlternateId(IdFormat.HexEntryId, ev.Details.StoreId, "someemail@domain.com"), IdFormat.EwsId);
var appointment = Appointment.Bind(service, new ItemId(convertedId.UniqueId));
foreach (var requiredAttendee in appointment.RequiredAttendees)
{
Console.WriteLine(requiredAttendee.Address);
}
}
精彩评论