无法使用Microsoft-Graph-API (Azure AD B2c)发送邮件。
我尝试过跟随代码,但没有成功。
IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(appId)
.WithTenantId(tenantId)
.WithClientSecret(clientSecret)
.Build();
ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication);
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
Message message = new Message
{
Subject = "Subject of mail",
Body = new ItemBody
{
ContentType = BodyType.Text,
Content = "Mail content",
},
ToRecipients = new List<Recipient>
{
new Recipient
{
EmailAddress = new EmailAddress
{
Address = email,
}
}
},
};
await graphClient.Me.SendMail(message).Request().PostAsync();它会给出以下错误:
Code: OrganizationFromTenantGuidNotFound
Message: The tenant for tenant guid 'xxxxxx' does not exist.
Inner error:
AdditionalData:
requestId: 0ecdb3f9-a210-4259-bd62-0c79e757d1f6
date: 2020-08-05T02:17:07
request-id: 0ecdb3f9-a210-4259-bd62-0c79e757d1f6
ClientRequestId: 0ecdb3f9-a210-4259-bd62-0c79e757d1f6注意:还提供了对Mail.Send的权限
发布于 2020-08-06 09:13:40
这是因为你的Azure AD B2C租户在O365订阅下没有Exchange online许可证。
因此,B2C用户没有邮箱来发送电子邮件,尽管它的UPN看起来像一个电子邮件地址。
如果可能,请尝试向租户分配O365订阅,并向B2C用户添加Exchange online许可证。
https://stackoverflow.com/questions/63270122
复制相似问题