microsoftgraph / microsoftgraph/msgraph-sdk-dotnet

graphServiceClient.Me.SendMail.PostAsync(requestBody)

Open
#1,681 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs: Attention :wave:
Dominant language
C#
Stars
789
Forks
264
Avg merge
15h 17m
Merged PRs (30d)
3

Description

Describe the bug
Using Graph v5.0.0
When attempting to send an email with the Microsoft.Graph.Me.SendMail method I'm getting the following error:

DemoGraph.Controllers.HomeController: Error: Error: Microsoft.Graph.Models.ODataErrors.ODataError: Exception of type 'Microsoft.Graph.Models.ODataErrors.ODataError' was thrown.
at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.ThrowIfFailedResponse(HttpResponseMessage response, Dictionary2 errorMapping, Activity activityForAttributes) at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendNoContentAsync(RequestInformation requestInfo, Dictionary2 errorMapping, CancellationToken cancellationToken)
at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendNoContentAsync(RequestInformation requestInfo, Dictionary2 errorMapping, CancellationToken cancellationToken) at Microsoft.Graph.Me.SendMail.SendMailRequestBuilder.PostAsync(SendMailPostRequestBody body, Action1 requestConfiguration, CancellationToken cancellationToken)
at DemoGraph.Graph.GraphServices.SendEmailMessage(String nameSendTo, GraphServiceClient graphServiceClient, String subject, String emailBody, ILogger log) in C:\Users\dadrape_adm\source\repos\DemoGraph\DemoGraph\Graph\GraphServices.cs:line 48
at DemoGraph.Controllers.HomeController.SendMail() in C:\Users\dadrape_adm\source\repos\DemoGraph\DemoGraph\Controllers\HomeController.cs:line 77

But when using the Microsoft.Graph.User.SendMail it working as expected

Expected behavior
Email is sent from the current logged in user.

Screenshots

Desktop (please complete the following information):

  • OS: Windows Server
  • Browser : chrome
  • Version: 110.0.5481.178

Additional context
Add any other context about the problem here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Microsoft.Graph.Me.SendMail.SendMailRequestBuilder.PostAsync and the caller in DemoGraph/Graph/GraphServices.cs line 48, then compare that request with the working Microsoft.Graph.User.SendMail call. Determine why the current-user request produces only an ODataError and verify that sending mail through the intended current-user path succeeds without the exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.