Thursday 2 June 2011

Retrieving Attachments From a SharePoint List Item

Today I had to retrieve a SPListItem's attachments in some code. I noticed that the SPListItem has this nice property called Attachments. I thought, "Sweet, this'll be really easy.", but upon closer inspection, the SPAttachmentCollection returned by this property only stores the names of the files attached to the SPListItem.

I decided to read up a bit just to make sure I wasn't just retrieving the items in the wrong way and I stumbled upon ' blog post about the subject in which he explains that you still had to navigate to the SPList's subfolders in order to find the actual files.

So, the Attachments property is useless when trying to retrieve the SPListItem's attachments. Like one of my collegues says "I wonder of they eat a bowl of stupid in the mornings."

No comments:

Post a Comment