Guest User

Untitled

a guest
Mar 20th, 2018
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. string siteCollectionUrl = "https://tenantname.sharepoint.com/sites/sitename";
  2. string userName = "username@tenant.onmicrosoft.com";
  3. string password = "yourpassword";
  4.  
  5. // Namespace: Microsoft.SharePoint.Client
  6. ClientContext ctx = new ClientContext(siteCollectionUrl);
  7.  
  8. // Namespace: System.Security
  9. SecureString secureString = new SecureString();
  10. password.ToList().ForEach(secureString.AppendChar);
  11.  
  12. // Namespace: Microsoft.SharePoint.Client
  13. ctx.Credentials = new SharePointOnlineCredentials(userName, secureString);
  14.  
  15. // Namespace: Microsoft.SharePoint.Client
  16. Site site = ctx.Site;
  17.  
  18. ctx.Load(site);
  19. ctx.ExecuteQuery();
  20. Web web = ctx.Web;
  21.  
  22. ctx.Load(web,w => w.ServerRelativeUrl,w => w.Lists);
  23.  
  24. List list = web.Lists.GetByTitle("List1");
  25.  
  26. ctx.Load(list);
  27. CamlQuery camlQuery = new CamlQuery();
  28. ListItemCollection itemColl = list.GetItems(camlQuery);
  29.  
  30. ctx.Load(itemColl);
  31. ctx.ExecuteQuery();
  32. foreach (ListItem item in itemColl)
  33.  
  34. {
  35. Console.WriteLine(item["Title"].ToString());
  36. foreach (var fieldValue in item.FieldValuesAsHtml.FieldValues)
  37. {
  38. Console.WriteLine(fieldValue.Key);
  39. Console.WriteLine(fieldValue.Value);//double quotes are replaced by "
  40. //eg. Check for "Continue demo.." button. is getting as
  41. //Check for "Continue demo.." button.
  42. }
  43. }
Add Comment
Please, Sign In to add comment