简体   繁体   中英

Microsoft Graph OrganizationFromTenantGuidNotFound when using mail.send

I would like to use Microsoft Graph and this works:

await graphClient.Users["xxxxxxx-xxxx-xxx-xxxx-xxxxxxx"]
                .Request()
                .GetAsync();

And this throws the OrganizationFromTenantGuidNotFound error:

await graphClient.Users["xxxxxxx-xxxx-xxx-xxxx-xxxxxxx"]
                .SendMail(message, false)
                .Request()
                .PostAsync()

I authenticate as an application with my client id, tenant id and secret.

I have set mail permissions in my app registration and the user is assigned.

Graph permissions with admin consent

I have tried to define the scope as "https://graph.microsoft.com/mail.send/.default" but then I get this error: MsalServiceException: AADSTS500011: The resource principal named https://graph.microsoft.com/mail.send was not found in the tenant...

I have also tried adding a new user to my app registration but that gives the same error.

My AAD account does have a Microsoft 365 Family subscription and I have an Azure trial account.

What else should I check? Thank you!

OrganizationFromTenantGuidNotFound comes mostly when there is no mailbox present.

You should have the Exchange Online License to work with SendMail endpoint because this endpoint is on exchange workload. And also, as you have specified the permissions in Azure AD you can simply add the scope as https://graph.microsoft.com/.default which pulls all the given permissions in Azure AD and add to your token.

Make sure you are using the Client Credential Flow(Application context) to get the App token.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM