Trying to create an appointment into a shared mailbox using the following code:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
service.Credentials = new WebCredentials("user_id", "password");
service.AutodiscoverUrl(user_id, RedirectionUrlValidationCallback); //resolves to https://outlook.office365.com/EWS/Exchange.asmx
Appointment meeting1 = new Appointment(service);
meeting1.Subject = "subject";
meeting1.Body = "body";
meeting1.Start = Convert.ToDateTime("some datetime");
DateTime end = Convert.ToDateTime("some datetime");
meeting1.End = end.AddMinutes(Convert.ToInt32("some number"));
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
Mailbox test = new Mailbox("some email");
FolderId folderid = new FolderId(WellKnownFolderName.Calendar, test);
meeting1.Save(folderid,SendInvitationsMode.SendToAllAndSaveCopy);
The error it returns is:
Access is denied. Check credentials and try again., The process failed to get the correct properties.
I know the credentials are correct because the call to AutodiscoverUrl
returned a valid URL. So im not sure why its saying "access is denied" when calling save()
?
Once again, answering my own question.
The particular user being passed needed to be granted write permissions to the mailbox folder in question.