- 07 February 2022
- SharePoint (4)
Steps
How to Add Form Attachments to Emails
Need to add attachments to your emails? The below flow shows how this can be done and works if there are no attachments, one attachment, or multiple. In a nutshell, we create an array to store the attachment data and an object of the upload form field using compose. Our condition then check the compose object to see if any data exists (i.e. if we have any attachments). If the object’s length is equal to zero (so ‘if yes’) we can go straight to sending the email as there are no attachments, otherwise (‘if no’) we can parse the data, append each attachment (with it’s properties) to the array we created earlier, then add that array to ‘attachments’ in the send an email action.
The schema used for the parse JSON action can be found further down the page.
Parse JSON schema:
{ "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "link": { "type": "string" }, "id": { "type": "string" }, "type": {}, "size": { "type": "integer" }, "referenceId": { "type": "string" }, "driveId": { "type": "string" }, "status": { "type": "integer" }, "uploadSessionUrl": {} }, "required": [ "name", "link", "id", "type", "size", "referenceId", "driveId", "status", "uploadSessionUrl" ] } }
Alternatively, the videos below explain how to do the same thing using a ‘scope’ action, and how to dump these files into the documents of a SharePoint site too.
How to add form attachments to an email (this example fails if no attachments exist):
You’ll find that the above works well if one or more attachments exist, but you’ll get an error if there are no attachments, i.e. for an optional question. The video below, by the same creator, expands on this by showing you how to handle non-required file upload questions using the ‘scope’ action:
Comments
Whether you have feedback, a question, want to share your opinion, or simply want to say thank you - we welcome comments! Please read the disclaimer.