send Mails sp.js

Utilities.SendMail = function (from,to, body, subject,success,error)
{
 //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: success,
 error: error
 });
 
}
Advertisements
This entry was posted in sharepoint online. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s