Tennant connection problem to mail api (Graph)

Frank Van diepenbos 0 Reputation points
2024-12-18T09:03:51.7766667+00:00

Hello,

  1. I'm trying to send and recieve emails with a c# application.
  2. I found out I needed to make some settings in the Azure portal.
    I have ClienId, TennantId and Client Secret.
  3. Then I found out I needed to get an Office365 subscription which I did.
  4. The error is now:
    {"error":{"code":"OrganizationFromTenantGuidNotFound","message":"The tenant for tenant guid 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' does not exist.","innerError":{"oAuthEventOperationId":"9xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","oAuthEventcV":"xxxxxxxxxxxxxxxxxxxxxxxxx","errorUrl":"https://aka.ms/autherrors#error-InvalidTenant","requestId":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","date":"2024-12-18T08:38:41"}}}
    ( i replaced the id's with x's)
  5. The application works fine with another microsoft account but I need to use my personal.
  6. It looks like I need to make a setting in Office ADmin portal which I cannot login to with a personal account.
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,793 questions
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 44,671 Reputation points
    2024-12-19T08:02:24.8733333+00:00

    Hi @Frank Van diepenbos

    If you are trying to use a personal account to log in to the app and call the Graph Mail API to send an email, then follow this:

    First, you'll need to register an app in your tenant that allows personal accounts to log in.

    User's image

    Next, use the authorization code flow to authenticate your personal account and generate an access token. Note that when logging in to a user and requesting a token, you need to change /{tenant_id} to /common.

    Finally, call the POST /me/sendMail API to send the email.

    User's image

    By the way, MS 365 license is not required for personal or social accounts. But for work accounts, MS 365 license is necessary.


    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.