2

I am getting a Internal Server 500 error when trying to send an email using the SP.Utilities.Utility.SendEmail in my SharePoint Online App. It is worth noting that I am working from a custom .aspx page that does not inherit from the Masterpage, and using AngularJS (thus the $http).

If I change the urlTemplate to use the hostWeb instead of the AppWeb, I get a 403 forbidden. Is there a library I need to include since I am using a custom.aspx page instead of the default.aspx page that comes when creating an App?

var appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
var urlTemplate = appweburl + "/_api/SP.Utilities.Utility.SendEmail";   

$http({
contentType: 'application/json',
url: urlTemplate,
type: "POST",
data: JSON.stringify({
    'properties': {
        '__metadata': {
            'type': 'SP.Utilities.EmailProperties'
        },
        'From': 'myname@myname.org',
        'To': {
            'results': ['yourname@myname.org']
        },
                            'Body': 'Hello',
                            'Subject': 'remember'
}
}),
headers: {
"Accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
}).success(function(data, status, headers, config) {
$scope.data = data;
alert("Email Sent!");
}).error(function(data, status, headers, config) {
$scope.status = status;
alert("Email FAil!");
});
  • did you find a solution for this? – wayzz Nov 6 '15 at 14:19
  • Not that I can recall. It has been a while since that project – Kode Nov 6 '15 at 16:32
2

I know this post is a bit old but I had the same problem and found out I had to set the SMTP outgoing in my Sharepoint Central Administrator.

  • Open the SharePoint 2013 Central Administration and go to System Settings and ClickConfigure outgoing e-mail settings. image This link is external to TechNet Wiki. It will open in a new window.

  • Click the email settings to configure the outgoing email server. set the Outbound SMTP server to your email server. From address should be any email address that can acceptably display in the "from" of email and Reply-to address similarly.

(Reference)

  • Can you please add details about how to do that, to make it really helpful – Robert Lindgren Nov 8 '15 at 13:36
  • Edited my answer, Hope it helps :) – wayzz Nov 8 '15 at 13:41

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.