Hello!
I am trying to include an attachment in some already working code that creates a new item in a SharePoint list. I have read that you can do this by including the attachment as a field in your CAML document. The field will hold an encoded string that represents the file. I want to do this using the CAML document.
Here is an example of the type of CAML document I am using already:
<?xml version="1.0" encoding="UTF-8" ?>
<Batch OnError="Continue">
<Method ID="1" Cmd="New">
<Field Name="Title" />
</Method>
</Batch>
Here is an example of how I would encode the XML infopath form file when I attach the file to the CAML (if possible, as an encoded string):
http://www.bizsupportonline.net/blog/2009/01/submit-infopath-form-sharepoint-list-attachment/
string formXml = MainDataSource.CreateNavigator().OuterXml;
byte[] attachment = Sytem.Text.Encoding.UTF8.GetBytes(formXml);
item.Attachments.Add("InfoPathForm.xml", attachment);
Here is an example of what I mean, a typical SharePoint list that can have attachments on each item.

I'm having trouble finding any sources that explain how to set up the CAML document properly. I believe I will be able to encode the file and insert it into the CAML without issue, but I'm not sure what the CAML needs to look like so that SharePoint will accept the field as an attachment.
- In the Project Explorer window in Microsoft Visual Studio Tools for Applications, right-click the node for the project name, and select Add Reference from the context menu.
- On the Add Reference dialog box, select Windows® SharePoint® Services from the list of components on the .NET tab, and click OK.