0
votes

I am designing a web part page (this page is called support page). If any body facing some issue he needs to fill up the form and send to email id. Forms is as follows:

First Name:

Last Name:

Issue Facing:

Date of Submission

Submit Button

Now on click of button I need to send data to a specific email id in SharePoint 2013 to administrator so that he can resolve the issue user is facing.

I am working on Provider hosted. So I have basic tools webpart, Script editor, webpart pages. I can write javascript just.

How will I send all this data to a specific email id in Sharepoint 2013. Client don't has Central administrator

Regards Basant Gera

1

1 Answers

0
votes

Please try the below code and let me know, if it works.

function sendEmail(from, to, body, subject) {
var urlTemplate = site + "/_api/SP.Utilities.Utility.SendEmail";
var formDigest = document.getElementById("__REQUESTDIGEST").value;
$j.ajax({
    contentType: 'application/json',
    url: urlTemplate,
    type: 'POST',
    data: JSON.stringify({
        'properties': {
            '__metadata': { 'type': 'SP.Utilities.EmailProperties' },
            'From': from,
            'To': { 'results': [to] },
            'Subject': subject,
            'Body': body
        }
    }
  ),
    headers: {
        "Accept": "application/json;odata=verbose",
        "content-type": "application/json;odata=verbose",
        "X-RequestDigest": formDigest
    },
    success: function (data) {
        var result = data.d.results;
        var i = result.length;
    },
    error: function (err) {
        alert(JSON.stringify(err));
    }
});}

call this function like this:

sendEmail("domain\\sender", "domain\\recipient","This is the body","Hello world");