How to change display name of sender to be different of email name in sending mail using c#

M C 0 Reputation points
2023-01-31T09:45:41.48+00:00
            Message message = new Message()
            {
                Body = new ItemBody
                {
                    Content = "test 123",
                    ContentType = BodyType.Text
                },
                ToRecipients = new List<Recipient>()
                {
                    new Recipient
                    {
                        EmailAddress=new EmailAddress
                        {
                            Address = "******@test.com"
                        }
                    }
                },
                From = new Recipient
                {
                    EmailAddress = new EmailAddress
                    {
                        Address = "******@mtest.com",
                        //It's not work - it's not change
                        Name = "display name that I want"
                    }
                },   
                Subject = "test123"
            };

I want to change only the display name of sender and It's not work 
It's return to the original name of the email address
Outlook Windows Classic Outlook for Windows For business
Microsoft Security Microsoft Graph
Developer technologies C#
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Gopinath Chennamadhavuni 2,446 Reputation points
    2023-01-31T11:34:29.5833333+00:00

    Hello @M C,

    Thanks for reaching out!

    Based on my knowledge, we can't do that with the Graph API as they will always resolve back to the original sender or check that you have rights (SendAS or SendOnBehalf) to the send from the particular address you're trying to use. It picks up the profile name and doesn't use the name (custom name) specified in the body of the post call. Currently, graph API doesn't support setting custom Email sender name.

    As a work around you can create a Shared Mailbox that has that address and give the accounts you want to use SendAS to that mailbox (or if your using App permission you should be good to go). Then create an AutoReply rule on the Shared Mailbox to indicate that messages sent to that address aren't monitored.

    Please find the similar post: https://learn.microsoft.com/en-us/answers/questions/1064522/microsoft-graph-send-email-with-custom-from-name

    Hope this helps.

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

    0 comments No comments

  2. Domingos Ricardi 0 Reputation points
    2023-03-29T19:22:33.79+00:00

    There is already feedback for this issue. Just vote for it to increase priority.

    https://feedbackportal.microsoft.com/feedback/idea/a8ed61ec-853d-ed11-a81b-000d3a7dd504


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.