Send Email with jQuery and REST API in SharePoint

As we all know every client is looking for the best performance and quick page loads. In this article, I would like to enhance your client-side skills by adding one more knowledge base. Here we will discuss how to send an email using jQuery and Rest API in SharePoint 2016/2013.

As soon as we configure SharePoint environment we ensure few important things for better user interface and experience one of them is email functionality. Without configuring this element user could not be able to perform below:

  • Configuring alerts
  • Email approval flow
  • Document library incoming email configuration
  • Sending emails through user / custom code blocks.

Send Email with jQuery and REST API in SharePoint

The below code block helps to send email to a user with the help of jQuery and REST service in SharePoint 2013/2016.

<script src=””></script>

function processSendEmails() {
    var from = ‘’,
        to = ‘’,
        body = ‘Hello World Body’,
        subject = ‘Hello World Subject’;
    alert(“Sending email to Krishna”);
    // Call sendEmail function
    sendEmail(from, to, body, subject);
    alert(“Email sent Successfully”);

function sendEmail(from, to, body, subject) {
    try {
        //Get the relative url of the site
        var siteurl = _spPageContextInfo.webAbsoluteUrl;
        alert(“Site URL=”+siteurl);
        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’: ‘’,
                    ‘To’: { ‘results’: [‘’] },
                    ‘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));
    catch (error) {
$(document).ready(function () {
    SP.SOD.executeFunc(‘sp.js’, ‘SP.ClientContext’, processSendEmails);

How does this code works?

  • Save this script as sendemail.js
  • Upload the script in sharepoint document / asserts library
  • Create a web part page add the content editor web part
  • Add the javascript in a content editor web part or script editor web part

If we read the code closely this script gets triggered on page load.

The output will be as follows.

Send Email with jQuery and REST API in SharePoint
Send Email with jQuery and REST API in SharePoint

You may like following SharePoint Rest API tutorials:

Hope this SharePoint tutorial helps to know how to send an email using jQuery and Rest API in SharePoint 2013/2016?

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

Krishna Vandanapu

I am Krishna.Vandanapu a SharePoint architect working in IT from last 13+ years, I worked in SharePoint 2007, 2010, 2013, 2016 and Office 365. I have extensive hands on experience in customizing SharePoint sites from end to end. Expertise in SharePoint migration tools like Sharegate, Doc Ave and Metalogix. Migrated SharePoint sites from SharePoint 2007 to 2010 and 2010 to 2013 several times seamlessly. Implementing CSOM with Microsoft best practices. Spent quality time in configuring SharePoint application services like User Profile, Search, Managed Meta data services etc. Now exploring SharePoint Framework and SharePoint 2019

  • ferran says:

    Hi, the alert ‘Email Sent Successfully’ shows me correctly, but I don’t receive any mail. Thanks!

  • Pawan says:

    Can we send outlook meeting request/Appointment in the same way?

  • sanjeet kumar says:

    Hi Krishna,

    Can we send email to Project owner when the project is created in Project Online and also email when the project owner will change and email trigger to new Project Owner. Kindly help on this.

  • >