I’ve been outside of this blog so far and never post anything in this blog. But let me share a small code snippet that can be used. Below is the code to send email from SharePoint.
var EmailInfo = {
To : { Address : 'radityo.ardi@gmx.com' },
Subject : 'This is the subject',
Body : 'This is the <b>Body</b>'
};
$.ajax({
url: _spPageContextInfo.webServerRelativeUrl +
'/_api/SP.Utilities.Utility.SendEmail',
contentType: 'application/json',
type: "POST",
headers: {
"Accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
data: JSON.stringify({
'properties': {
'__metadata': { 'type': 'SP.Utilities.EmailProperties' },
'From': 'Radityo Ardi',
'To': { 'results': [EmailInfo.To.Address] },
'CC': [],
'Subject': EmailInfo.Subject,
'Body': EmailInfo.Body
}
}),
success: function(dataSendEmail) {
alert('Email successfully sent.');
},
error: function(err) {
console.log(err);
}
});