是否使用exchange web服务获取日历项目所需的与会者?c#

是否使用exchange web服务获取日历项目所需的与会者?c#,c#,outlook,add-in,exchangewebservices,C#,Outlook,Add In,Exchangewebservices,我正在尝试获取使用exchange web服务获得的会议所需的与会者。有什么想法吗?我想我需要使用CalendarItemType,但我不确定如何实现它。 以下是我目前的代码: foreach (var wrk in Workers) { TimeWindow timeWindow = new TimeWindow(startDate, endDate); AvailabilityData requestedData

我正在尝试获取使用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?
                 }
             }
         }
foreach(工人中的var wrk)
{
TimeWindow TimeWindow=新的时间窗口(开始日期、结束日期);
AvailabilityData requestedData=AvailabilityData.FreeBusy;
列表与会者=新列表();
添加(新与会者信息(wrk.EmailAddress));
GetUserAvailabilityResults ares=service.GetUserAvailability(与会者、时间窗口、请求数据);
foreach(ares.AttendesAvailability中的与会者可用性av)
{
foreach(平均CalendarEvents中的CalendarEvent ev)
{
//从每个日历事件获取信息
//可能在这里使用CalendarItemType?
}
}
}

其中Workers是一个I类,包含姓名和相应电子邮件地址的列表。

您可以通过绑定到约会来检索所需的与会者,使用:

在调用
约会.Bind
之前,您可能必须将
CalendarEvent.Details.StoreId
转换为其他格式(我不确定这一点),因此如果上述代码不起作用,您可以尝试添加对以下内容的调用:


谢谢你,但两者都不起作用。第二种方法为Appointment.Bind提供错误,因为参数convertedId的格式为AlternateIdBase,并且它请求ItemId。关于如何解决这个问题,你有什么想法吗?@Sam:我稍微修改了代码,在调用Appointment.Bind时使用ItemId。为什么约会时需要新的ItemId。Bind只是使用我从FindAppointment方法获得的ItemId?@fernandotores:问得好。我不知道微软为什么选择这样做。
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);
    }
}
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);
    }
}