SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am able to add an item to a list using the CAML below. Now I need to modify it to make sure I can add an attachment as well. What is the syntax to add an attachment?

<?xml version="1.0" encoding="UTF-8"?>
<Batch OnError="Continue">
    <Method ID="1" Cmd="New">
       <Field Name='Title'></Field>
       <Field Name="FirstName"></Field>
       <Field Name="LastName"></Field>
share|improve this question
up vote 1 down vote accepted

The SharePoint Object Model may be better suited for this task. Try looking at the code examples from MSDN about how to work with the Microsoft.SharePoint.SPListItem class.

Also, here are a few more code examples to check out:

share|improve this answer
hmm. Not sure about using object model. I am trying to follow this article on infopath. – Robin Li Jul 30 '12 at 20:15

Apparently, to attach a file to an item is not possible. You have to get the _ows_ID value when creating the item, then use the AddAttachment method on the ID value of your item.

Please see the similar thread:

share|improve this answer
You answers is good as well. Thanks you for the heads up. – Robin Li Jul 31 '12 at 14:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.