1

我正在尝试在 C# 中为 sharepoint 编写一个邮件发送器,但每次启动它时,我都会收到此错误消息,告诉我它没有权限。

我尝试在 AppManifest.xml 授予它权限,但我不知道是哪个...我尝试了所有但没有任何接缝来提供帮助。

我的代码:

private void SendEmail( ClientContext clientContext )
{
    User sendToUser = clientContext.Web.EnsureUser( "mymail@mail.com" );
    clientContext.Load( sendToUser );
    clientContext.ExecuteQuery();

    string email = Microsoft.SharePoint.Client.Utilities.Utility.GetCurrentUserEmailAddresses( clientContext ).Value;

    Microsoft.SharePoint.Client.Utilities.EmailProperties properties = new Microsoft.SharePoint.Client.Utilities.EmailProperties();
    properties.To = new string[] { sendToUser.Email };
    properties.Subject = "subject";
    properties.Body = "body";

    Microsoft.SharePoint.Client.Utilities.Utility.SendEmail( clientContext, properties );

    clientContext.ExecuteQuery();
}

有人对我有什么建议吗?

4

2 回答 2

0

授予发件人(当前用户)“管理警报”权限

于 2016-04-22T12:49:41.697 回答
0

感觉不对。您应该无法使用客户端代码中的服务器资源发送电子邮件。

有关解决方案,请参阅https://sharepoint.stackexchange.com/questions/97354/send-email-from-csom

于 2016-04-21T21:04:20.403 回答