I want to send email using Javascript/jQuery using REST API in SharePoint.
I have tried _api/SP.Utilities.Utility.SendEmail
and this is my code:
Code
$.ajax({
contentType: 'application/json',
url: urlEmail,
type: "POST",
data: JSON.stringify({
'properties': {
'__metadata': { 'type': 'SP.Utilities.EmailProperties' },
'Body': 'Hello',
'To' : { 'results': ['[email protected]'] },
'Subject': "From REST API"
}
}),
headers: {
"Accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function (data) {
alert("Successful");
},
error: function (err) {
alert(err.responseText);
}
});
Error
The e-mail message cannot be sent. Make sure the e-mail has a valid recipient.