Sunday, August 14, 2011

Access SharePoint list item attachements through code

The code to access the list item attachements is a really simple code.
The attachments of a list item are stored as a collection of files for each list item.
This collection can be access through the Attachments property of the SPListItem object.

An example code is shown below.

// get a reference to the attachments collection
SPAttachmentCollection attachments = listItem.Attachments;
// loop through each file in the collection
foreach(SPFile in attachments)
    // your logic

1 comment: