0

Have done the Google research and also searching here with no real solid luck with using Microsoft.SharePoint and Microsoft.SharePoint.Cient for VB .Net. Can anyone help with how to upload an Excel workbook as an attachment to a list. We have the site uri, list name and item IDs. Just not sure how to do it with MicrosoftSharePoint.Client. We are using the code below to capture fields of each item of the list. Also, a reference to or breif explanation of the difference between Microsoft.SharePoint.Client and Microsoft.SharePointOnline.CSOM? Is CSOM primarily for Online SharePoint? We’re able to use Microsoft.SharePoint.Client accessing Online SharePoint list, is there advantage of switching to the CSOM references?

        Try
            Using clientContext As New ClientContext(szSiteUrl)

                clientContext.Credentials = credentials

                Dim oWebsite As Microsoft.SharePoint.Client.Web = clientContext.Web
                clientContext.Load(oWebsite, Function(w) w.Title, Function(w) w.Description)
                clientContext.ExecuteQuery()
                Dim lists As IEnumerable(Of List) = clientContext.LoadQuery(oWebsite.Lists)
                clientContext.ExecuteQuery()

                Dim Query As String =
                    "<View Scope='RecursiveAll'>" &
                        "<Query>" &
                            "<ViewFields>" &
                                "<FieldRef Name='RECORD_NUMBER'/>" &
                                "<FieldRef Name='Title'/>" &
                                "<FieldRef Name='ID'/>" &
                            "</ViewFields>" &
                        "</Query>" &
                    "</View>"

                Dim collList As ListCollection = oWebsite.Lists
                Dim oList As List = collList.GetByTitle(szListName)
                'Create a CAML Query\
                Dim CQuery As CamlQuery = CamlQuery.CreateAllItemsQuery()
                CQuery.ViewXml = Query

                'Create a Collection
                Dim ColListItems As ListItemCollection = oList.GetItems(CQuery)
                Try
                    'Load and execute the request to SharePoint server
                    clientContext.Load(ColListItems)
                    clientContext.ExecuteQuery()
                Catch ex As Exception
                    Throw New Exception("Problem Accessing List", ex)
                End Try
            End Using
        Catch ex As Exception

        End Try

Thank you for any assistance.

Benny H.
  • 25
  • 5

0 Answers0