Microsoft 365 Email: not possible to set custom sender name

Dmytro Maliuta 0 Reputation points
2024-07-23T07:51:44.0266667+00:00

Hi!

I am trying to send a message by POST /me/sendMail endpoint: https://learn.microsoft.com/uk-ua/graph/api/user-sendmail?view=graph-rest-1.0&tabs=http

My request body looks like this:

{
    "message": {
        "body": {
            "content": "test content",
            "contentType": "html"
        },
        "from": {
            "emailAddress": {
                "address": "dmytro.maliuta@mail.com",
                "name": "Test sender"
            }
        },
        "subject": "test subject",
        "toRecipients": [
            {
                "emailAddress": {
                    "address": "john.doe@mail.com"
                }
            }
        ]
    }
}

As you can see I have a custom sender name in the from object (message.from.emailAddress.name), but when I send a message the sender name is not the same as I have in the request body. Is it an error on Microsoft's side? Can someone help with this?

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

1 answer

Sort by: Most helpful
  1. Yakun Huang-MSFT 4,720 Reputation points Microsoft Vendor
    2024-07-23T08:36:32.5266667+00:00

    Hi @Dmytro Maliuta

    This is not an error. According to the documentation, the from property indicates the owner of the mailbox from which the message was sent. The value must correspond to the mailbox actually used. This value cannot be changed in most cases, even if you customize it when sending the request, except in sharing or delegation scenarios.

    User's image

    If you need to set the sender details of the message, you need to follow the following scenario:

    User's image

    See the link below for more details:

    https://learn.microsoft.com/en-us/graph/api/resources/message?view=graph-rest-1.0#properties

    https://learn.microsoft.com/en-us/graph/outlook-create-send-messages#set-the-from-and-sender-properties

    Hope this helps.

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


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.