AddAttachment
Adds an attachment to a SharePoint list item. Useful for linking supplementary files to SharePoint records.
Stored Procedure-Specific Information
The AddAttachment stored procedure adds an attachment to a list item in SharePoint. You can specify the attachment content either by providing a local file path using the File parameter, or by providing the content directly using the Content parameter.To add an attachment from a local file, enter:
EXEC AddAttachment File = 'C:\path\to\AddAttachment.txt', List = 'TestList', ItemID = '1', FileName = 'AddAttachment.txt';
The stored procedure returns the URL of the uploaded attachment on success.
Input
| Name | Type | Required | Description |
| File | String | False | The full path of the local file to be uploaded as an attachment. |
| List | String | True | The name of the SharePoint list where the attachment will be added. |
| ItemID | String | True | The unique identifier of the list item to which the attachment will be added. |
| FileName | String | False | The name of the file to be uploaded as an attachment, including the file extension (such as 'document.pdf'). This is used if 'Content' is not null. |
Result Set Columns
| Name | Type | Description |
| Success | Boolean | Indicates whether the attachment was successfully added. Returns 'true' for success and 'false' for failure. |
| URL | String | The URL of the newly created attachment in SharePoint. |