Using exchange web services to get the required attendees of a calendaritem? c#

人盡茶涼 提交于 2019-12-10 17:43:00

问题


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.


回答1:


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);
    }
}


来源:https://stackoverflow.com/questions/6915309/using-exchange-web-services-to-get-the-required-attendees-of-a-calendaritem-c-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!