使用 javascript 发送邮件的 Sharepoint 权限

Sharepoint permissions to send mail with javascript

我正在用它发送电子邮件

function sendEmail(from, to, body, subject) {
//Get the relative url of the site
var siteurl = _spPageContextInfo.webServerRelativeUrl;
var urlTemplate = siteurl + "/_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": jQuery("#__REQUESTDIGEST").val()
    },
    success: function(data) {
        alert('Email Sent Successfully');
    },
    error: function(err) {
        alert('Error in sending Email: ' + JSON.stringify(err));
    }
});

}

当我与一个管理员用户一起尝试时这有效,但是具有贡献权限的 "standard" 用户收到以下错误:

"error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access denied. You do not have permission to perform this action or access this resource."}}

我直接向用户地址发送电子邮件,而不是向群组地址发送电子邮件。 我已将其添加到贡献权限中,但仍然没有成功:

Use Remote Interfaces  -  Use SOAP, Web DAV, the Client Object Model or SharePoint Designer interfaces to access the Web site.

我不知道我还能尝试什么,

有什么帮助吗?

谢谢

您是否将电子邮件发送给其他 SharePoint 用户?

This method supports sending email messages only to valid SharePoint user email addresses.

发件人:https://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.utilities.sputility.sendemail.aspx

贡献权限级别没有 "send alerts" 权限。

添加该权限后 ir 起作用了