Close this search box.

Sending email with SharePoint and jQuery

Want to send email from SharePoint using jQuery? No problem!

No need to create workflows or set up SMTP servers, just use this simple function:

function sendEmail(from, to, body, subject) {
  var siteurl = _spPageContextInfo.webServerRelativeUrl;

  var urlTemplate = siteurl + "/_api/SP.Utilities.Utility.SendEmail";
	   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) {

This works nicely on SharePoint online, apparently it works on OnPremise as well. Just note that the recipient is limited to a valid SharePoint user for security reasons.

This article is part of the GWB Archives. Original Author: Thorvald Bøe

Related Posts