Office 365 Exchange EWS:"Access is denied. Check credentials and try again., The process failed to get the correct properties."

Office 365 Exchange EWS: "Access is denied. Check credentials and try again., The process failed to get the correct properties."

正在尝试使用以下代码在共享邮箱中创建约会:

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);

它 returns 的错误是:

    Access is denied. Check credentials and try again., The process failed to get the correct properties.

我知道凭据是正确的,因为对 AutodiscoverUrl 的调用返回了有效的 URL。所以我不确定为什么它在调用 save() 时说“访问被拒绝”?

再次回答我自己的问题。

被传递的特定用户需要被授予对相关邮箱文件夹的写入权限。