0

From a SharePoint hosted app, I want to send some emails in my sharepoint hosted app which will be deployed to office 365 tenants. Is there any code i can add in my app which will send emails to clients ? or maybe notifications ?

2

You can use REST Endpoint SP.Utilities.Utility.SendEmail for sending mails in SharePoint Hosted app. Example: 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));
    }
});

Source: How to send email in SharePoint Hosted apps 2013 for SharePoint Foundation?

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.