标签:func relative fun cli request app poi site .so
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); });
标签:func relative fun cli request app poi site .so
原文地址:http://www.cnblogs.com/olay/p/7851571.html