MsProject技术交流群207637602

sharepoint rest 脚本发送邮件

function processSendEmails() { var from = 'asad@Example.com', to = 'someone@Example.com', body = 'Hello World Body', subject = 'Hello World Subject'; // Call sendEmail function // sendEmail(from, to, body, subject); } function sendEmail(from, to, body, subject) { //Get the relative url of the site var siteurl = _spPageContextInfo.webServerRelativeUrl; var urlTemplate = siteurl + "/_api/SP.Utilities.Utility.SendEmail"; $.ajax({ contentType: 'application/json', url: urlTemplate, type: "POST", data: JSON.stringify({ 'properties': { '__metadata': { 'type': 'SP.Utilities.EmailProperties' }, 'From': from, 'To': { 'results': [to] }, 'Body': body, 'Subject': subject } }), headers: { "Accept": "application/json;odata=verbose", "content-type": "application/json;odata=verbose", "X-RequestDigest": jQuery("#__REQUESTDIGEST").val() }, success: function(data) { alert('Email Sent Successfully'); }, error: function(err) { alert('Error in sending Email: ' + JSON.stringify(err)); } }); } $(document).ready(function () { SP.SOD.executeFunc('sp.js', 'SP.ClientContext', processSendEmails); });

posted @ 2017-11-17 14:47  鳄鱼的眼泪  阅读(305)  评论(0编辑  收藏  举报

专业MSProject,QQ411033149