How can we send email from microsft graph api to third party email providers like gmail/yahoo using asp.net

Aneesh A.S 6 Reputation points
2021-09-01T17:28:09.777+00:00

Hi,
How can we send email from microsoft graph api to third party email providers like gmail/yahoo using asp.net

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

2 answers

Sort by: Most helpful
  1. Danstan Onyango 3,821 Reputation points Microsoft Employee
    2021-09-02T09:10:06.297+00:00

    First, please add the code or request payload you are using to send mail and include the inner error details. You error is 404 and seems to be because you are using an account that does not have a mailbox.

    As for sending mail from Graph to other third party providers, you just need to use MS Graph SendMail and add the emails in the payload. Here is a sample I have used to send mail to Gmail from Exchange.

    POST https://graph.microsoft.com/v1.0/me/sendMail  
    {  
        "message": {  
            "subject": "Meet for lunch?",  
            "body": {  
                "contentType": "Text",  
                "content": "The new cafeteria is open."  
            },  
            "toRecipients": [  
                {  
                    "emailAddress": {  
                        "address": "myname@otherdomain.com"  
                    }  
                }  
            ],  
            "ccRecipients": [  
                {  
                    "emailAddress": {  
                        "address": "myname@gmail.com"  
                    }  
                }  
            ]  
        },  
        "saveToSentItems": "false"  
    }  
    

    But as I said, your problem seems to be with an account that does not have a mail box. Try again and share the details requested.

    1 person found this answer helpful.

  2. Aneesh A.S 6 Reputation points
    2021-09-15T09:58:28.383+00:00

    hi,
    I have attached the permissions, which is applied in the account.

    132411-permissions.png

    1 person found this answer helpful.
    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.