0
votes

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!

1
Please mark it as the answer by clicking the check mark. Doing so helps others find answers to their questions. See meta.stackexchange.com/questions/5234/….Shiva Keshav Varma

1 Answers

0
votes

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.