0

I have a function who sends email like:

function sendEmailProveedor(emailSpan, fromMail, body, subject) {

   var appweburl = _spPageContextInfo.webAbsoluteUrl;
  var urlTemplate = appweburl + "/_api/SP.Utilities.Utility.SendEmail";
  var headers = {
      "Accept": "application/json;odata=verbose",
      "content-type": "application/json;odata=verbose",
      "X-RequestDigest": $("#__REQUESTDIGEST").val()
  };
      // if recipient isn't an array make it one
      emailSpan = Array.isArray(emailSpan) ? emailSpan : [emailSpan];

      var payload = {'properties': {
                        '__metadata': { 'type': 'SP.Utilities.EmailProperties'},
                        'From': fromMail,
                        'To': {'results': ['gerardo@gmail.com']},
                        'Body': body,
                        'Subject': subject
                      }
      };

      return $.ajax({
          contentType: 'application/json',
          url: urlTemplate,
          type: "POST",
          headers: headers,
          data: JSON.stringify(payload)
      });
  }

But I have a 400 error, and it occurs for SPUtility Limitation, only can send email to AD users like this post

{"readyState":4,"responseText":"{\"error\":{\"code\":\"-2130242040, Microsoft.SharePoint.SPException\",\"message\":{\"lang\":\"en-US\",\"value\":\

"The e-mail message cannot be sent. Make sure the e-mail has a valid recipient.\"}}}","status":400,"statusText":"Bad Request"}

There is any alternative to send email to users that not are in Active directory? Regards

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.