0

I have created a form in a list, and one of the fields required is a person/group field that I would like to send a notification email to when the form is submitted. I have a button at the bottom of the form and would like to assign a rule on the button to generate an email. I am having trouble finding the correct field to enter into the "to" section of the email.

1

The easiest way would be to create SharePoint Designer workflow which would run after the new item has been created. In it you can use Email action and select the field which holds the person as the receiver of the email.

More on creating simple SharePoint designer workflows can be found here.

  • Is there a way to create a workflow to send the notification when a certain button is clicked? Right now I have a "save & Submit" "approve" and "deny" button that I would need the email notification for. So just having it for when the item is created would not suffice. – user74066 Feb 19 '18 at 16:21
0

You can use this snippet on button click :

function processSendEmail() {  

if ($("#empEmailId").val() != null) {  
    var userEmaiId = $("#empEmailId").val();  
}  
else {  

    alert("EmailId Should not be empty");  
}  



var From = '';  
var To = userEmaiId;  
var Body = 'You have been successfully submitted the data to List';  
var SubjectOfEmail = 'Email Notification Using REST API';  


sendEmailNotification(From, To, Body, SubjectOfEmail);  

}

function sendEmailNotification(From, To, Body, SubjectOfEmail) {

hostWebUrl = decodeURIComponent(manageQueryStringParameter('SPHostUrl'));  

var constructedURL = appWebUrl + "/_api/SP.Utilities.Utility.SendEmail";  
$.ajax({  
    contentType: 'application/json',  
    url: constructedURL,  
    type: "POST",  
    data: JSON.stringify({  
        'properties': {  
            '__metadata': { 'type': 'SP.Utilities.EmailProperties' },  
            'From': From,  
            'To': { 'results': [To] },  
            'Body': Body,  
            'Subject': SubjectOfEmail  
        }  
    }  
  ),  
    headers: {  
        "Accept": "application/json;odata=verbose",  
        "content-type": "application/json;odata=verbose",  
        "X-RequestDigest": $("#__REQUESTDIGEST").val()  
    },  
    success: function (data) {  
        alert('Email Sent Successfully');  


    },  
    error: function (err) {  
        alert('Error in sending Email: ' + JSON.stringify(err));  


    }  
});  

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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