Below is the send email functionality based on SP.js
As we can see below we have TO field commented out.
Call 1: Sending to single user
var msg="html message to send";
buildContent.sendEmail("admin@test.com", "user@test.com" , msg, "Alert Notification!!");
in that case uncomment the line
// 'To': { 'results': [to] },
and comment the next line.
If we want to send to multiple users and SharePoint user Groups.
Call 2:
var to = [];
to.push("testUser1@test.com");
to.push("testUser2@test.com");
to.push("Site Owners");
var msg="html message to send";
buildContent.sendEmail("admin@test.com", to, msg, "Alert Notification!!");
sendEmail: function (from, to, body, subject) {
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] },
'To': { 'results': to }, //
'Body': body, 'Subject': subject
} } ),
headers: { "Accept": "application/json;odata=verbose", "content-type": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val() }, success: function (data) { alert("Email send"); }, error: function (err) { alert(err.responseText);
// debugger;
} }); },
reference : http://blogs.msdn.com/b/spses/archive/2014/10/24/you-can-t-specify-the-from-address-for-email-messages-when-you-use-the-quot-send-an-email-quot-option-from-a-sharepoint-designer-2013-workflow-action.aspx
var msg="html message to send";
buildContent.sendEmail("admin@test.com", "user@test.com" , msg, "Alert Notification!!");
in that case uncomment the line
// 'To': { 'results': [to] },
and comment the next line.
If we want to send to multiple users and SharePoint user Groups.
Call 2:
var to = [];
to.push("testUser1@test.com");
to.push("testUser2@test.com");
to.push("Site Owners");
var msg="html message to send";
buildContent.sendEmail("admin@test.com", to, msg, "Alert Notification!!");
sendEmail: function (from, to, body, subject) {
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] },
'To': { 'results': to }, //
'Body': body, 'Subject': subject
} } ),
headers: { "Accept": "application/json;odata=verbose", "content-type": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val() }, success: function (data) { alert("Email send"); }, error: function (err) { alert(err.responseText);
// debugger;
} }); },
reference : http://blogs.msdn.com/b/spses/archive/2014/10/24/you-can-t-specify-the-from-address-for-email-messages-when-you-use-the-quot-send-an-email-quot-option-from-a-sharepoint-designer-2013-workflow-action.aspx