The mail sending process is a POST method and so it uses a metadata content which is to be passed with different parameters as shown below.
The metadata includes the Sender’s and recipient’s email addresses along with the Subject and body of the mail.
function Mail(){
$.ajax({
contentType: ‘application/json’,
url: “https://sitename/_api/SP.Utilities.Utility.SendEmail”,
type: “POST”,
data: JSON.stringify({
‘properties’: {
‘__metadata’: { ‘type’: ‘SP.Utilities.EmailProperties’ },
‘From’: ‘Sender’s email address’,
‘To’: { ‘results’: [‘recipient’s Email address’] },
‘Body’: ‘<h1>Hello!!</h1><p>This is mail was sent from a client side function</p>’,
‘Subject’:’Send eMail’
}
}
),
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(JSON.stringify(err));
}
});
}
Can you help by documenting how you implement this via SharePoint designer step by step since I am not familiar ?
LikeLike