In sharepoint hosted app how to send mail using js.I want send email to any user,not only for sharepoint user.
2 Answers
You can mail SharePoint users from JavaScript via the REST interface (sample from this thread):
function sendEmail(from, to, body, subject) {
appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
var urlTemplate = appweburl + "/_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": $("#__REQUESTDIGEST").val()
},
success: function (data) {
console.log('success')
},
error: function (err) {
console.log(JSON.stringify(err));
}
});
}
As far as I know you can not do that for external e-mail addresses via the out-of-the-box solutions provided by SharePoint.
A possible workaround: You can implement your own E-Mail sender service, make it available via REST, and call this interface from your SP hosted app.
-
This code is send mail to only sharepoint user.I want to send email to any user.Sarika Koli– Sarika Koli2016-08-10 10:55:17 +00:00Commented Aug 10, 2016 at 10:55
-
This 'minor' information was missing from your original question. As far as I know you can not do that via the solutions provided out-of-the-box by SharePoint.pholpar– pholpar2016-08-10 11:20:42 +00:00Commented Aug 10, 2016 at 11:20
-
SharePoint can only mail to AD contacts, If it could send to anyone in the world SharePoint would have been the number one Spam tool in the world.Danny '365CSI' Engelman– Danny '365CSI' Engelman2016-08-10 11:24:10 +00:00Commented Aug 10, 2016 at 11:24
-
so @Danny '365CSI' Engelman is there any solution for this?Madhav– Madhav2016-08-10 11:56:43 +00:00Commented Aug 10, 2016 at 11:56
-
@Danny'365CSI'Engelman You can send to any email address using a 2010 workflow.Jordan– Jordan2016-08-10 12:54:22 +00:00Commented Aug 10, 2016 at 12:54
Please refer this similar post
Note: As per @Danny commented, SharePoint can only mail to AD contacts.
-
this article is not workSarika Koli– Sarika Koli2016-08-11 04:48:08 +00:00Commented Aug 11, 2016 at 4:48
-
It is a similar asked question and please refer given first answer which is also marked as true answer..SID– SID2016-08-11 06:35:00 +00:00Commented Aug 11, 2016 at 6:35
-
using SP.Utilities.Utility.SendEmail api Send mail to only SP users & I want to send mail to any user...Sarika Koli– Sarika Koli2016-08-11 06:37:38 +00:00Commented Aug 11, 2016 at 6:37
-
As i have written one note "Note: As per @Danny commented, SharePoint can only mail to AD contacts".. For security reasons the recipient is limited to a valid SharePoint user .SID– SID2016-08-11 06:44:38 +00:00Commented Aug 11, 2016 at 6:44
-
Using Sharepoint Hosted app I want to send mail to any user.It is possible or not?Sarika Koli– Sarika Koli2016-08-11 06:46:27 +00:00Commented Aug 11, 2016 at 6:46