Hi @Liviu Dumitrescu
Since you're calling the /users/{user id}
endpoint to send mail on behalf of another user, you need application permissions and not delegated permissions. The application permission requires you to statically consent to all permissions, so please delete the Dynamics 365 permission in tenant 1 first, and then re-grant the Dynamics 365 permission after the administrator of tenant 2 consents to your multi-tenant application.
https://login.microsoftonline.com/{organization}/adminconsent?client_id={client-id}
var requestBody = new Microsoft.Graph.Users.Item.SendMail.SendMailPostRequestBody
{
Message = new Message
{
Subject = "Meet for lunch?",
Body = new ItemBody
{
ContentType = BodyType.Text,
Content = "The new cafeteria is open.",
},
ToRecipients = new List<Recipient>
{
new Recipient
{
EmailAddress = new EmailAddress
{
Address = "frannis@contoso.onmicrosoft.com",
},
},
},
CcRecipients = new List<Recipient>
{
new Recipient
{
EmailAddress = new EmailAddress
{
Address = "danas@contoso.onmicrosoft.com",
},
},
},
},
SaveToSentItems = false,
};
await graphClient.Users["{user-id}"].SendMail.PostAsync(requestBody);
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.