使用Exchange Web服务,以获得一个calendaritem的要求与会者? C#
我试图让我得到了使用Exchange Web服务的会议所需的与会者。有任何想法吗?我想我需要使用CalendarItemType,但我不知道如何实现它。
这是我到目前为止的代码:
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?
}
}
}
那里的工人是一类我其名称和相应的电子邮件地址列表的。
Where Workers is a class I made with a list of names and corresponding email addresses.
您可以通过结合使用预约 Appointment.Bind
:
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);
}
}
您可能要转换 CalendarEvent.Details.StoreId
为不同的格式之前调用 Appointment.Bind
(我不知道这个),所以如果上面的代码是不是工作你可以尝试添加一个调用的 ExchangeService.ConvertId
:
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);
}
}