SharePoint Online allows users to share documents only as links. Documents links are created based on requested permissions, that can be shared with end users. Primary reason for this is to keep documents within SharePoint, giving more control over who has access and auditing around views/edits. Recently we came across a requirement, where users wanted to send document as email attachment, to users who don’t have O365 access or don’t want to go through the hassle of logging in.
To send a document as an email attachment, you can create a workflow using Microsoft Flow. Here are few more things to consider:
- User should be able to send the document from any site/library with this functionality enabled. Flow should not be bound to a specific library.
- We should be able to trigger the Flow from other areas of the site e.g. custom web part, not just document list view.
Follow the steps below to setup the Flow:

Step 1 – When an HTTP request is received
Flow allows HTTP request as a trigger. You can send a POST request with specified parameters to trigger the FLOW.
Here are the parameters:
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "emailSubject": { "type": "string" }, "emailBody": { "type": "string" }, "emailAddress": { "type": "string" }, "fileRef": { "type": "string" }, "fileLeafRef": { "type": "string" }, "siteUrl": { "type": "string" } }, "required": [ "emailAddress", "emailSubject", "emailBody", "siteUrl", "fileRef", "fileLeafRef" ] }
Step 2 – Get File Content
In this step, we retrieve the content of the document from specified site and file path.
We use Flow Action – ‘SharePoint – Get file content’
Specify ‘Site Address‘ and ‘File Identifier‘ from fields retrieved from previous step.
Step 3 – Send an email
File content retrieved in Step 2, are used here as an email attachment. We use ‘Office 365 Outlook – Send an email’ action to send the email, as in image below.
Note, ‘fileLeafRef’ is the file name with extension. File Content retrieved does not provide file name. FileleafRef can be passed in HTTP request as here, or retrieved using another action to get file properties.
Step 4 – Response
Returns an HTTP response as JSON, indicating completion of the flow.
In case of an error, flow will return respective error back.
Your flow is ready.
Testing
To test this, you need to send HTTP POST request to URL from HTTP Request action (Step 1).
You can use Postman app to send the test request to this URL
Resources: - Get started with Microsoft Flow