How to Send Email in SharePoint Online/Office 365 using REST API?

Hello SharePointers,

Here is the blog that discusses about sending email in SharePoint Online/Office 365 using REST API.

function sendEmailusingRESTAPI(from, to, body, subject) {
var urlTemplate = appweburl + “/_api/SP.Utilities.Utility.SendEmail”;
var formDigest = GetDigest();
$.ajax({
contentType: ‘application/json’,
url: urlTemplate,
type: ‘POST’,
data: JSON.stringify({
‘properties’: {
‘__metadata’: { ‘type’: ‘SP.Utilities.EmailProperties’ },
‘From’: from,
‘To’: { ‘results’: [“to”] },
‘Subject’: subject,
‘Body’: body
}
}
),
headers: {
“Accept”: “application/json;odata=verbose”,
“content-type”: “application/json;odata=verbose”,
“X-RequestDigest”: formDigest
},
success: function (data) {
var result = data.d.results;
var i = result.length;
},
error: function (err) {
alert(JSON.stringify(err));
}
});
}

Happy SharePointing 🙂

Leave a Reply

Your email address will not be published.