'Microsoft Graph Sendmail API error- Error invalid user

Sendmail method in Graph giving error "The requested user is invalid"



Solution 1:[1]

The user which you are using to send email doesn't exist in your O365 tenant.

Please check the users' email account in O365 admin center.

And make sure to assign an Exchange Online license to the user.

Just choose the user and click on "Edit" next to Product licenses.

enter image description here

And then select a subscription which includes Exchange Online, for example Microsoft 365 E3.

Solution 2:[2]

Try this.. it works..

fromUserEmail is any valid user of your tenant

IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder .Create(clientId) .WithTenantId(tenantID) .WithClientSecret(clientSecret) .Build();

ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication);

GraphServiceClient graphClient = new GraphServiceClient(authProvider);

string fromUserEmail [email protected]

graphClient.Users[fromUserEmail ].SendMail(message, true).Request().PostAsync().ConfigureAwait(false).GetAwaiter().GetResult();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Allen Wu
Solution 2 Preeti