Go to Entra portal → App registrations → New registration


Name the app (e.g., MyService-Mailer)
Supported account types: Single tenant
Redirect URI: Not required
Click Register

Copy:
Directory (tenant) ID
Application (client) ID
These will be used by your service to request OAuth tokens.
In your app → Certificates & secrets
Click New client secret
Set an expiration period (1–2 years recommended)
Copy the VALUE immediately — you cannot retrieve it later
You now have:
Client ID
Client Secret
Tenant ID
Then
You need Mail.Send (Application) — NOT delegated.
App → API permissions

Add a permission → Microsoft Graph → Application permissions
Add Mail.Send

Click Grant admin consent