c# - Get calendar tasks for several employees using EWS -
i need store appointment data several exchange calendars. right have solution loops through group containing employees using:
expandgroupresults mygroupmembers = service.expandgroup("allusers@....onmicrosoft.com"); foreach (emailaddress address in mygroupmembers.members){ service.impersonateduserid = new impersonateduserid(connectingidtype.smtpaddress, address.address); datetime startdate = datetime. datetime enddate = startdate.adddays(7); calendarfolder calendar = calendarfolder.bind(service, wellknownfoldername.calendar, new propertyset()); calendarview cview = new calendarview(startdate, enddate); cview.propertyset = new propertyset(appointmentschema.subject, appointmentschema.start, appointmentschema.end); finditemsresults<appointment> appointments = calendar.findappointments(cview); foreach (appointment in appointments) { file.write(address.address + ";"); file.write(a.subject.tostring() + ";"); file.write(a.start.tostring() + ";"); file.write(a.end.tostring() + ";"); file.writeline(); } }
using service.impersonateduserid
each employee slow, have done similar?
update fetch data around 100 employees mygroupmembers. if way go go since can't find solution.
one option optimize remove unnecessary calendarfolder.bind line. reduce 1 call per address. also, returning full folder property set aren't using throw away data sent on wire.
then replace calendar.findappointments line exchangeservice.finditems method. have finditems call target calendar folder, , give calendarview.
that should reduce number of calls 50%.
Comments
Post a Comment