gpt4 book ai didi

c# - 如何使用 Microsoft Graph API 发送邀请电子邮件

转载 作者:行者123 更新时间:2023-12-02 00:13:06 25 4
gpt4 key购买 nike

我想邀请我们的 Active Directory/租户中的用户。为此,使用 Micorosoft Graph API。代码使用如下

  IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithTenantId(tenantID)
.WithClientSecret(clientSecret)
.Build();

ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication);

GraphServiceClient graphClient = new GraphServiceClient(authProvider);

var invitation = new Invitation
{
InvitedUserEmailAddress = "myemailaddress@gmail.com",
InviteRedirectUrl = "https://myapp.com"
};

await graphClient.Invitations
.Request()
.AddAsync(invitation);

在此之后,我可以在 Azure 的事件目录门户中看到该用户。但不要收到邀请电子邮件。

但是,当我从 Azure 门户单击重新发送邀请 时,邀请电子邮件就来了。

能否请您指导,为什么从 API 发送邀请时没有收到邀请邮件?

最佳答案

您需要在 Invitation 对象中将 SendInvitationMessage 设置为 true:

var invitation = new Invitation
{
InvitedUserEmailAddress = "myemailaddress@gmail.com",
InviteRedirectUrl = "https://myapp.com",
SendInvitationMessage = true
};

有关更多信息,您可以阅读 Docs

sendInvitationMessage Boolean Indicates whether an email should be sent to the user being invited or not. The default is false.

关于c# - 如何使用 Microsoft Graph API 发送邀请电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58216580/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com