1

In sharepoint hosted app how to send mail using js.I want send email to any user,not only for sharepoint user.

3

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 Aug 10 '16 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 Aug 10 '16 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 Aug 10 '16 at 11:24
  • so @Danny '365CSI' Engelman is there any solution for this? – Madhav Aug 10 '16 at 11:56
  • @Danny'365CSI'Engelman You can send to any email address using a 2010 workflow. – Jordan Aug 10 '16 at 12:54
0

Please refer this similar post

Note: As per @Danny commented, SharePoint can only mail to AD contacts.

  • this article is not work – Sarika Koli Aug 11 '16 at 4:48
  • It is a similar asked question and please refer given first answer which is also marked as true answer.. – SID Aug 11 '16 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 Aug 11 '16 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 Aug 11 '16 at 6:44
  • Using Sharepoint Hosted app I want to send mail to any user.It is possible or not? – Sarika Koli Aug 11 '16 at 6:46

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.