1

I'm working on an E-Mail function for a SharePoint 2013 provider-hosted App.

The code I'm currently using:

// Prepare the E-Mail parameters
EmailProperties properties = new EmailProperties();
properties.Subject = subject;
properties.To = new string[] {toEmailAddress};
properties.Body = "<html><body>" + htmlBodyContent + "</body></html>";
properties.AdditionalHeaders = new Dictionary<string, string>() 
{
    {"Reply-To", fromEmailAddress},
    {"Content-Type", "text/html"}
};

// Send the mail over SharePoint
Utility.SendEmail(clientContext, properties);
clientContext.ExecuteQuery();

This Code works perfectly in my Office 365 SharePoint Development Site. But it does not work on the Client's on-premises SharePoint.

The clientContext.ExecuteQuery() function throws an ServerUnauthorizedException , telling me that the Access was Denied for the operation.

The App has the same Permissions in the O365 SP as it has in the on-premises SP. Also both SharePoint Servers have a working outgoing E-Mail configuration and are both able to send E-Mails to Users.

Are there any differences between sending Emails in on-prem SharePoints and sending them in an Office 365 SharePoints? Which permissions does the sending of E-Mails require?

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.