SendMail(message).Request().PostAsync() method doesnot guarentee message delivery?

Shailesh Bopche 11 Reputation points Microsoft Employee
2022-03-21T13:44:02.917+00:00

Im using MS Graph API to send emails using a service account. I have followed the official documentation provided by Microsoft for the same operation https://learn.microsoft.com/en-us/graph/api/user-sendmail?view=graph-rest-1.0&tabs=csharp

Im not able to figure out why SendMail(message).Request().PostAsync() doesnot send email but SendMail(message).Request().PostResponseAsync().GetAwaiter().GetResult() does.

Need help with the reason behind it. Thanks in advance

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,592 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. CarlZhao-MSFT 36,896 Reputation points
    2022-03-22T08:06:29.447+00:00

    Hi @Shailesh Bopche

    I tested this code snippet and it doesn't seem to be a problem, I can send emails correctly. After the code is working correctly, you still haven't received any mail in outlook?

    185465-image.png

    185526-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. CarlZhao-MSFT 36,896 Reputation points
    2022-03-22T10:28:35.273+00:00

    Hi @Shailesh Bopche

    After testing, I reproduced your problem locally and it is indeed not possible to use C# to call users/{user id} to send mail (testing with postman seems to work). I will submit this bug with the graph product team later, please wait for my update.

    0 comments No comments

  3. Jim Pallett 1 Reputation point
    2022-07-25T15:28:41.02+00:00

    Any update?

    0 comments No comments