sharepoint - send email use rest-api
function SendEmail(from, to, cc, body, subject) {
var urlTemplate = _spPageContextInfo.webAbsoluteUrl + "/_api/SP.Utilities.Utility.SendEmail";
var formDigest = $("#__REQUESTDIGEST").val();
return $.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
}
}).then(function (data) {
console.log(data);
},function (data) {
//alert(JSON.stringify(err));
console.log(data);
});
}
sendEmailToCategoryOwner:function(){
var from = this.currentUserEmail;
var body = "<div style='font-family:\"Times New Roman\";'>"+
"<p style='font-size:16px'>Dear xxx,</p>"+
"<p style='font-size:16px'>The Project - " + this.infoForm.projectName + " has been submitted in xxx pending for your review & approval.</p>"+
"<p style='font-size:16px'>Please login <a href='https://xxx.aspx?itemId="+ this.currentId +"'><i style='font-size:16PX;color:#0066CC;font-style:normal'>xxx</i></a> to check it.</p>"+
"<p style='font-size:16px'>Thanks!</p>"+
"</div>";
var subject = "Approver reminder";
SendEmail(from,to,'',body,subject));
}
学贵有恒,而行胜于言