DownloadAttachment
Downloads an attachment from a SharePoint list item. Allows users to access and retrieve important files.
Stored Procedure-Specific Information
The DownloadAttachment stored procedure downloads an attachment from a SharePoint list item. You can save the attachment to a local file using the File parameter, or retrieve the content as base64-encoded data using the FileData output.To download an attachment to a local file, enter:
EXEC DownloadAttachment File = 'C:\path\to\DownloadAttachment.txt', RemoteFile = 'https://mysite.sharepoint.com/testsite/Lists/testlist/Attachments/1/test.txt';
To retrieve the attachment content as base64-encoded data, omit the File parameter:
EXEC DownloadAttachment RemoteFile = 'https://mysite.sharepoint.com/testsite/Lists/testlist/Attachments/1/test.txt';
Input
| Name | Type | Required | Description |
| File | String | False | The local path where the downloaded attachment should be saved, including the new filename. Example: 'C:/Users/User/Desktop/Attachment.pdf'. |
| RemoteFile | String | True | The path of the attachment on the SharePoint server. This can be the full URL (such as 'https://yoursharepointsite.com/Shared Documents/attachment.pdf') or just the file name. If only the name is provided, the latest version will be downloaded. |
Result Set Columns
| Name | Type | Description |
| Success | Boolean | Indicates whether the download operation was successful. Returns 'true' if successful, otherwise 'false'. |
| FileData | String | The BASE64 encoded content of the downloaded attachment. This is only returned if File and FileStream are not specified. |