更新和删除日历事件,而不向与会者发送通知

时间:2019-09-25 08:39:35

标签: microsoft-graph

我们需要通过MS Graph API从用户日历中更新/删除约会事件,不发送通知与会者。我找不到任何方法来控制它。在EWS API中,我们能够使用选项进行控制。

appointment.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToNone);

我们找到了更新的解决方法。如果我们创建一个新的空Event对象实例并设置现有约会的I​​D和自定义属性数据,则不会发送通知。这对于我们的情况就足够了。但是,我们不能将其用于删除。

1 个答案:

答案 0 :(得分:0)

您可以像以前一样使用Microsoft Identity Client nuget软件包和 OAuthCredentials 继续使用EWS。您必须通过Azure应用注册授予 EWS.AccessAsUser.All 权限。这是到目前为止我发现删除EWS基本身份验证的最佳方法。

string clientId = "Your Clinet Id";
string tenantId = "your Tenant Id";
string[] scopes = { "https://outlook.office365.com/EWS.AccessAsUser.All" };
Microsoft.Identity.Client.IPublicClientApplication publicClientApplication = Microsoft.Identity.Client.PublicClientApplicationBuilder.Create(clientId).WithTenantId(tenantId).Build();

System.Security.SecureString secureString = new System.Security.SecureString();
foreach (char ch in password)
     secureString.AppendChar(ch);

Microsoft.Identity.Client.AcquireTokenByUsernamePasswordParameterBuilder authBuilder = publicClientApplication.AcquireTokenByUsernamePassword(scopes, userName, secureString);
Microsoft.Identity.Client.AuthenticationResult result = await authBuilder.ExecuteAsync();

ExchangeService service = new ExchangeService
{
     Credentials = new OAuthCredentials(result.AccessToken)
};