AddAttachment Method

The AddAttachment method of the Lists service adds an attachment to the specified list item in the specified list.

Parameters

listName   A string that contains either the title or the GUID for the list.

listItemID   A string that contains the ID of the item to which attachments are added. This value does not correspond to the index of the item within the collection of list items.

fileName   A string that contains the name of the file being added as an attachment.

attachment   A byte array that contains the file to attach using base-64 encoding.

Return Value

A string that contains the URL for the attachment, which can subsequently be used to reference the attachment.

Example

The following code example adds a local file as an attachment to a specified list item. The example uses a System.IO.FileStream object to read the source file into a byte array that is passed as a parameter of the AddAttachment method.

This example requires that a using (C#) or Imports (Visual Basic .NET) directive be included for the System.IO namespace. The example also assumes the existence of a text box in the form of the Windows Application.

Requirements

Platforms: Microsoft Windows Server 2003

Web Reference: http://Server_Name/[sites/][Site_Name/]_vti_bin/Lists.asmx