What license do I need to be able to send emails through Microsoft Graph via an unattended desktop app?

WesWilliams-4769 65 Reputation points
2025-01-10T21:41:32.8166667+00:00

Context: I'm a developer who writes console programs that scrape web sites. When an event occurs, I send an email to myself. MS recently turned off basic authentication. No sample program anywhere on the internet works to send via Microsoft Graph or other (no Twilio Sendmail or 3rd party service please. MS blocks them).

Question: What Azure service or license do I need to be able to send emails from an unattended Windows Desktop program to myself?

This web site says I need a license" https://zimmergren.net/sending-e-mails-using-microsoft-graph-using-dotnet/

I have a MS Office 365 Subscription

I have an entra application with client secrets and API Permissions for Mail.Read and Mail.Send

I have no problem authenticating. It's when I do "mail.send" when it says "Unauthorized"

Tried and Failed:

  • I've set up a MS Entra Client Secret.
  • I've tried sending with PublicClientApplicationBuilder and got this on
  var request = new HttpRequestMessage(HttpMethod.Post, "https://graph.microsoft.com/v1.0/me/sendMail")
  
  { Content = requestContent };
  request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
  
  var response = await httpClient.SendAsync(request);`

Unauthorized

{"error":{"code":"OrganizationFromTenantGuidNotFound","message":"The tenant for tenant guid '00000000-f40e-4889-977c-67abc6b1ea17' does not exist.","innerError":{"oAuthEventOperationId":"ade9420d-f3ba-4a2f-bdf9-cc02f213455d","oAuthEventcV":"3Z1lS49nvGfZCpcrkoKZnQ.1.1","errorUrl":"https://aka.ms/autherrors#error-InvalidTenant","requestId":"670f3d80-8c63-4353-9135-4ff203e7e78f","date":"2025-01-10T21:14:42"}}}

Yes, the tenant ID is correctly set

Microsoft 365 and Office | Development | Other
Microsoft Security | Microsoft Entra | Microsoft Entra Internet Access
Windows for business | Windows Client for IT Pros | Devices and deployment | Licensing and activation
Microsoft Security | Microsoft Graph
{count} votes

Accepted answer
  1. Anonymous
    2025-01-13T07:48:31.8733333+00:00

    Hello We s,

    Thank you for reaching out to Microsoft Support!

    Yes, as you said, sending emails with the Application permissions of the Graph API is not supported by the Home version, you need the Business version account, for which you can view this link.

    For Home accounts, you can only Send Mail through the /me/sendMail endpoint, which requires the delegated permission mail.send, for which you need to use auth code flow for an interactive login to get the token.

    Hope this helps.

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


1 additional answer

Sort by: Most helpful
  1. Kavya 490 Reputation points
    2025-01-11T13:32:23.9333333+00:00

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.