我正在尝试获得使用Exchange Web服务的会议所需的与会者。有任何想法吗?我想我需要使用CalendarItemType,但我不确定如何实现它。 到目前为止,这是我的代码:
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?
}
}
}
如果工人是我使用名单和相应电子邮件地址列出的课程。
答案 0 :(得分:6)
您可以使用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);
}
}
在调用CalendarEvent.Details.StoreId
之前,您可能需要将Appointment.Bind
转换为其他格式(我对此不确定),因此如果上述代码无效,您可以尝试添加对{{{ 3}}:
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);
}
}