Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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>
   </Method>
</Batch>
share|improve this question
add comment

2 Answers

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.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitem.aspx

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

http://nehasinha.wordpress.com/2008/05/23/programmticallyc-adding-deleting-copying-and-downloading-attachments-in-splist/

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
add comment

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: http://stackoverflow.com/questions/4100157/add-attachment-with-updatelistitems.

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

Your Answer

 
discard

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.