Forum Discussion
Not able to send emails to the external users in SharePoint 2013- on premises
The error message suggests that the receipent of the email to send is either not set or not properly set. Sending emails with the REST api is limited to valid SharePoint users for security reasons. You can't send to external addresses.
- anandrk4891Apr 03, 2018Copper Contributor
Thanks Stephan for the reply, is there any alternate for rest api through which i can send email notification to the external users on button click (external users are getting site share notification ... i tried with designer list workflow to send notification but its sending mails to internal user but not for external)
- Charles PritchardApr 04, 2018Copper Contributor
Hi there,
I've had to go through this headache with external emails as well as attachments and whilst I can't give you our actual solution I'm sure I can give you some pointers.
Firstly head into portal.azure.com and go to 'Azure AD' and create a new application. From there you can set it use the 'Exchange API' and give it several permissions based on what your scope for the project is.
https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applications
Once that's done, go into the manifest of the AD App and change 'AllowImplicitFlow' to 'true'.
Now you have to set each Sharepoint web page that would be using this app in the Azure AD App - 'Reply URLS'
The next difficult part is considering security and protecting the Access Key exposed in an OAuth handshake. There's pages and pages on this stuff and I'd be wasting your time here. Once you've done the previous steps you can leverage whatever frameworks to authorize and protect the token.
https://jwt.io/ for example is a great standard.
https://msdn.microsoft.com/en-us/office/office365/api/mail-rest-operations
https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-code
The main sticking points for me were the combination of different query parameter's required,
Here's what worked for me:
clientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" (Azure AD App)
replyUrl = "https://tenant.sharepoint.com/reply.aspx" (You Decide)
endpointUrl = "https://outlook.office.com/api/v2.0/me/messages"
resource = "https://outlook.office.com/"authServer = "https://login.windows.net/common/oauth2/authorize?"
responseType = "token"url = authServer +
"response_type=" + responseType + "&" +
"client_id=" + clientId + "&" +
"resource=" + resource + "&" +
"redirect_uri=" + replyUrlI have also found you can pass small strings in the "state" query parameter, it can be useful for certain functions in your SP solutions.
Hope this helps you out with your dev work.