sharepoint - send email use rest-api
阿新 • • 發佈:2020-12-28
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 One Governance Approver,</p>"+ "<p style='font-size:16px'>The Project - " + this.infoForm.projectName + " has been submitted in One Governance Platform pending for your review & approval.</p>"+ "<p style='font-size:16px'>Please login <a href='https://team.apac.sp.wp.corpintra.net/sites/09283/SitePages/Detail.aspx?itemId="+ this.currentId +"'><i style='font-size:16PX;color:#0066CC;font-style:normal'>One Governance Platform</i></a> to check it.</p>"+ "<p style='font-size:16px'>Thanks!</p>"+ "</div>"; var subject = "Approver reminder"; SendEmail(from,to,'',body,subject)); }