DownloadAttachment
Downloads an attachment from a SharePoint list item. Useful for accessing and retrieving necessary documents.
Stored Procedure Specific Information
RemoteFile can be both relative to the server, or it can be the full URL of the file. Below are some examples:
EXECUTE DownloadAttachment File = 'C:/Users/User/Desktop/DownloadedFile.txt', RemoteFile = 'https://mysite.sharepoint.com/Lists/MyCustomList/Attachments/1/FileToDownload.txt'; EXECUTE DownloadAttachment File = 'C:/Users/User/Desktop/DownloadedFile.txt', RemoteFile = '/Lists/MyCustomList/Attachments/1/FileToDownload.txt';
Input
| Name | Type | Required | Description |
| File | String | False | The local file path where the downloaded attachment will be saved. If not specified, the file content may be returned in FileData or written to a stream. |
| RemoteFile | String | True | The path of the file on the SharePoint server. Can be a full URL or just the file name. If only the name is provided, the latest version is downloaded. |
| Encoding | String | False | Specifies the character encoding format for the downloaded data. Determines how the data is read and processed.
The allowed values are NONE, BASE64. The default value is BASE64. |
| ReadTimeout | String | False | The maximum number of seconds allowed for the download operation. If exceeded, the operation fails, unlike Timeout, which only triggers if the download stalls. |
Result Set Columns
| Name | Type | Description |
| Success | Boolean | Indicates whether the attachment download operation was successful. Returns 'true' for success and 'false' for failure. |
| FileData | String | Contains the downloaded file content as binary data. Only returned if neither File nor FileStream is specified. |