Microsoft Graph API sendEmail request sent sent to myself not shown in the outlook inbox?

AranBit 20 Reputation points
2024-10-25T06:28:29.9733333+00:00

I'm using Microsoft Graph API to send emails from my application.

The user logs in using Microsoft to get an access token, then the app enabled sending emails to others and also to himself.

My issue is that emails that are sent from the user to the user itself("me") are shown in the sent items(which is fine), but are not shown in the outlook inbox.

The following is the command I'm using:

http.post(
  Uri.parse('https://graph.microsoft.com/v1.0/me/sendMail'),
  headers: {
    'Content-type': 'application/json',
    'Authorization': 'Bearer $accessToken',
  },
  body: jsonEncode(
    {
      "message": {
        "subject": subject,
        "body": {
          "contentType": contentType,
          "content": message,
        },
        "toRecipients": {
          "emailAddress": {"address": userEmail@domain.com},
        }
      }
    },
  ),
);
Outlook
Outlook
A family of Microsoft email and calendar products.
3,975 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,227 questions
{count} votes

Accepted answer
  1. Hitesh Pachipulusu - MSFT 2,915 Reputation points Microsoft Vendor
    2024-10-25T07:18:04.6633333+00:00

    Hello AranBit,

    Thank you for reaching out to Microsoft Support!

    It sounds like you're encountering an issue where emails sent to oneself using the Microsoft Graph API are not appearing in the Outlook inbox. This can happen due to several reasons:

    1. Junk Email Filters: Sometimes, emails sent to oneself can be filtered out as junk or spam. Check the Junk Email folder to see if the emails are being redirected there.
    2. Mail Flow Rules: There might be mail flow rules set up in your Exchange Online environment that are affecting the delivery of these emails. Verify if any rules are in place that could be moving these emails to other folders.
    3. API Permissions: Ensure that the application has the necessary permissions to send and receive emails. The permissions should include Mail.Send.

    I have tested the Graph API in my tenant and able to see the mail in Inbox and Sentitems folder. Please check below.

    image (6)

    image (5)

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.


1 additional answer

Sort by: Most helpful
  1. Yakun Huang-MSFT 6,340 Reputation points Microsoft Vendor
    2024-10-25T08:54:03.2+00:00

    Hello AranBit,

    Thank you for reaching out to Microsoft Support!

    Add the "saveToSentItems": "false" parameter to the body of your request. As shown in the picture below:

    Screenshot 2024-10-25 085150

    Reference document:

    https://learn.microsoft.com/en-us/graph/api/user-sendmail?view=graph-rest-1.0&tabs=http#request-body

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    0 comments No comments

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.