Deepak  chauhan

Deepak chauhan

  • NA
  • 1
  • 904

How we can Call java script function in code behind (c#) for

Jul 14 2015 6:27 AM

Hi All,

Please suggest how we can Call below java script function in code behind (c#) . Below function is used to send an Email so how we can call this function in code behind (C#)

function sendEmail(from, to, body, subject) {
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": $("#__REQUESTDIGEST").val()
},
success: function (data) {
alert("Thank you for the review!");
},
error: function (err) {
alert(err.responseText);
debugger;
}
});
}
 
Thanks
Deepak Chauhan 

Answers (2)