Skip to content

Instantly share code, notes, and snippets.

@vman
Created November 29, 2013 11:55
Show Gist options
  • Select an option

  • Save vman/7704688 to your computer and use it in GitHub Desktop.

Select an option

Save vman/7704688 to your computer and use it in GitHub Desktop.
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.UserProfiles;
using System;
using System.IO;
using System.Security;
namespace ImgSetter
{
class Program
{
static void Main(string[] args)
{
using (ClientContext clientContext = new ClientContext("https://yoursite.sharepoint.com/"))
{
SecureString passWord = new SecureString();
foreach (char c in "yourpassword".ToCharArray()) passWord.AppendChar(c);
clientContext.Credentials = new SharePointOnlineCredentials("[email protected]", passWord);
var peopleManager = new PeopleManager(clientContext);
System.IO.Stream stream = new FileStream(@"C:\imgToSetAsProfilePic.jpg",FileMode.Open);
peopleManager.SetMyProfilePicture(stream);
clientContext.ExecuteQuery();
Console.WriteLine("Profile Picture Set");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment