exchangewebservices - How could I fetch multiple o365 mail details for mail ids using EWS managed API in c# -
i need fetch multiple o365 mail details different mail ids using ews managed api in c#. suppose have o365 mail ids 1,2,3...
when pass these mail ids , call ews managed api details mail ids should populated. have done details population single email id using code below:
exchangeservice service = new exchangeservice(exchangeversion.exchange2013_sp1); service.credentials = new webcredentials("username", "password"); service.autodiscoverurl(ownerusername, redirectionurlvalidationcallback); emailmessage mail = emailmessage.bind(service, mailid, propertyset.firstclassproperties);
if has suggestion please share.
try this:
exchangeservice service = new exchangeservice(exchangeversion.exchange2013_sp1); service.credentials = new webcredentials("username", "password"); service.autodiscoverurl(ownerusername, redirectionurlvalidationcallback); //make sure include properties looking in emailmessageschema propertyset propset = new propertyset(basepropertyset.idonly, emailmessageschema.subject, emailmessageschema.torecipients); //add ids stored in database here var itemids = new list<itemid>(); foreach(var mailids in db.mails.select(a=>a.ids)) { itemids.add(new itemid(mailids)); } //send 1 request ews , mails id serviceresponsecollection<getitemresponse> response = service.bindtoitems(itemids, propset); //get emails foreach (getitemresponse getitemresponse in response) { item item = getitemresponse.item; emailmessage message = (emailmessage)item; }
Comments
Post a Comment