Madhav

Madhav

  • NA
  • 196
  • 43.6k

sending mail to any email id using sharepoint hosted app

Aug 16 2016 1:10 AM
i want to send email to any email id using SharePoint hosted app but am enable to do that,the thing i found that allows me to send email to sharepoint users only ,am using bellow code
 
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("Eposten ble sendt");
},
error: function (err) {
alert(err.responseText);
debugger;
}
});
}
 
 
 
can any one help me to resolve this issue? 

Answers (4)