I want to send email on the click of my customnewform.aspx while saving data in SharePoint online by using SharePoint Designer..

You can create a List Workflow to send an email and trigger the workflow on item creation.So indirectly when you will click save the item will be created and which will result in workflow to trigger and email will be send.

  • Thanks, any other solution..? – RajeshSharepointGeek Jan 8 at 7:55
  • 1
    Why do you need another solution? Sunil's answer will achieve what you need. – Tally Jan 8 at 8:43

Using the SharePoint Designer Workflow is an easy method.

Another method, you can send email using Rest Api and bind it to click event of the Save button.

function processSendEmails() {

    var from = 'admin@tenant.onmicrosoft.com',
        to = 'user@ tenant.onmicrosoft.com',
        body = 'content',
        subject = 'subject';

    // Call sendEmail function
    sendEmail(from, to, body, subject);
}


function sendEmail(from, to, body, subject) {
    //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: function(data) {
            alert('Email Sent Successfully');
        },
        error: function(err) {
            alert('Error in sending Email: ' + JSON.stringify(err));
        }
    });
}

$(document).ready(function () {

    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', processSendEmails);

});

Demo about how to send email using Rest Api in SharePoint Online:

https://social.technet.microsoft.com/wiki/contents/articles/36955.sharepoint-2013spo-send-email-using-rest-api.aspx

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.