In How to use the SharePoint object model to submit data from an InfoPath browser form to a SharePoint list I showed you how you can use the SharePoint Object Model to save the data from an InfoPath form as an item in a SharePoint list.
If you want to take this a bit further and also attach the entire InfoPath form to the SharePoint list item you created, you can add the following C# code just before the item.Update() line:
string formXml = MainDataSource.CreateNavigator().OuterXml;
byte[] attachment = Sytem.Text.Encoding.UTF8.GetBytes(formXml);
item.Attachments.Add("InfoPathForm.xml", attachment);
Now when the InfoPath form is submitted to the SharePoint list, the XML of the entire InfoPath form will be stored as an attachment to the SharePoint list item.
Note:
You do not have to limit yourself to saving the entire InfoPath form as an attachment to the SharePoint list item. You could for example also extract data from fields on the InfoPath form, use this data to create a text file or even a Word document, and attach this text file or Word document as an attachment to the SharePoint list item. The possibilities are endless!

Comments to this post were closed 30 days after it was published.