'EWS managed API - get bulk meeting list from multiple rooms (parallel)

I would like to get all meetings from calendars in multiple rooms. What is the best approach? That is the code snippet that I'm experimenting with:

System.Threading.Tasks.Parallel.ForEach(rooms, room =>
            {
                try
                {
                    var cView = new Exchange.CalendarView(startTime, endTime, numberOfMeetings);
                    var calendarFolderId = new Exchange.FolderId(Exchange.WellKnownFolderName.Calendar, room);

                    var appointments = _exchangeService.FindAppointments(calendarFolderId, cView);

                    meetings = appointments.Items;
                    if (meetings.Any())
                    {
                        _exchangeService.LoadPropertiesForItems(meetings, new Exchange.PropertySet(
                            Exchange.ItemSchema.Id,
                            Exchange.AppointmentSchema.ICalUid,
                            Exchange.AppointmentSchema.RequiredAttendees,
                            Exchange.AppointmentSchema.OptionalAttendees,
                            Exchange.AppointmentSchema.Start,
                            Exchange.AppointmentSchema.End,
                            Exchange.AppointmentSchema.Location,
                            Exchange.AppointmentSchema.IsMeeting,
                            Exchange.AppointmentSchema.Organizer
                        ));
                    }

                    var test = meetings;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            });

rooms - room email

The above code snippet gives me an exception: An item with the same key has already been added. Key: Set-Cookie

If I run it in a normal loop it works but is slow.

is there a better idea to have multiple request to EWS for data?

stack: .net core and EWS



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source