In my previous article, I explained how to fetch access token to consume Graph API. In this article, we will discuss how to send an email from SharePoint using Microsoft Graph API. You can read the previous part here.
HTTP Request
- POST https://graph.microsoft.com/v1.0/{userid | userprincipalname}/sendMail
- POST https://graph.microsoft.com/v1.0/me/sendMail
The above HTTP requests help in sending the email.
Let's open Microsoft Graph Explorer and send a test message to my personal email.
Navigate to:
https://developer.microsoft.com/en-us/graph/graph-explorer
https://developer.microsoft.com/en-us/graph/graph-explorer
Log in to your Office 365 work or school account.
In Graph Explorer, navigate to Outlook Mail section where there are plenty of HTTP requests with different activities.

Now, I am using POST request for sending an email to my personal Gmail account with the help of Graph API.
Click on "Send an email".
Request Header - Content-Type - application/json
Request Body in JSON format -
- {
- "message": {
- "subject": "Test Message from Microsoft Graph Explorer",
- "body": {
- "contentType": "Text",
- "content": "This is the test email body message from microsoft graph api"
- },
- "toRecipients": [{
- "emailAddress": {
- "address": "[email protected]"
- }
- }]
- }
- }

Click "Run Query".
The request is successful. You are able to see the below message from the Graph Explorer.

So now, I am going to open my email inbox to check if the mail has been sent from Microsoft Graph API Explorer.
So, in the next step, I am going to send the HTTP Request from jquery AJAX. Open SharePoint and create an HTML form for sending an email.
HTML Code
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- <body>
- <div class="container">
- <div class="form-group">
- <label for="email">To:</label>
- <input type="email" class="form-control" id="email" required>
- </div>
- <div class="form-group">
- <label for="txtsubject">Subject:</label>
- <input type="text" class="form-control" id="txtsubject" required>
- </div>
- <div class="form-group">
- <label for="txtmessage">Message:</label>
- <textarea class="form-control" id="txtmessage" rows="7" required></textarea>
- </div>
- <button type="submit" onclick="sendEmail();" class="btn btn-default">Send</button>
- </div>
- </body>


Bhanuprakash BysaniPosted Oct 23, 2018, 7:53 AM
I am getting an error in send email function as Access is denied. Check credentials and try again.
Love ThakkerPosted Sep 5, 2018, 7:19 AM
Make sure you are passing space after Bearer in header in send mail. "headers": { "authorization": "Bearer " + token, //Pass the token to authorize the API request "content-type": "application/json" }
Chintan SanghaviPosted Sep 4, 2018, 9:27 AM
Well explained Vinod....Solved one of my query.
Satyaprakash SamantarayPosted May 16, 2018, 11:19 AM
Nice one .... very clear description