c# - Exchange Web Services - accessing calendar of group mailbox using service account -
i trying access group mailbox using exchange web services.
a domain account full access group mailbox has been setup, getting following error:
when making request account not have mailbox, must specify mailbox primary smtp address distinguished folder ids.
my code below:
exchangeservice service = new exchangeservice(exchangeversion.exchange2013); service.usedefaultcredentials = false; service.credentials = new webcredentials("serviceaccount", "<password>"); //find web service url service.autodiscoverurl("<group mailbox email address>", redirectionurlvalidationcallback); //find calendar id folderid folderid = new folderid(wellknownfoldername.calendar, new mailbox("<group mailbox email address>")); //find calendar calendarfolder calendar = calendarfolder.bind(service, folderid); //create calendarview calendarview view = null; var propertyset = new propertyset( appointmentschema.id, appointmentschema.subject, appointmentschema.start, appointmentschema.end ); view = new calendarview(datetime.now.addmonths(-1), datetime.now.addmonths(1)); view.propertyset = propertyset; //get appointments var appointments = calendar.findappointments(view);
is there way of achieving without setting mailbox service account?
when run above code credentials, there no issues (i have full permission group mailbox, , mailbox of own).
use impersonation. code works great me connect shared mailbox service account.
exchangeservice service = new exchangeservice(exchangeversion.exchange2013_sp1); service.credentials = new networkcredential(service_acct, password); // set impersonation shared mailbox service.impersonateduserid = new impersonateduserid(connectingidtype.smtpaddress, "sharedmbx@contoso.com");
Comments
Post a Comment