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

We s 0 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 Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,750 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,141 questions
Microsoft Entra Internet Access
Microsoft Entra Internet Access
A Microsoft Entra service that provides an identity-centric Secure Web Gateway that protects access to internet, software as a service (SaaS), and Microsoft 365 apps and resources.
29 questions
Windows Licensing
Windows Licensing
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.Licensing: Rules, regulations, and restrictions that define how software can be used and distributed.
124 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Kavya 0 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.