How to Set Theme to a site in SharePoint Online Or Office 365 programmatically using CSOM?

Hi All,

In this article, we will learn about setting Theme to a SharePoint site in Office 365 using CSOM. Below is the sample CSOM code to achieve the same.

ClientContext clientContext= new ClientContext(siteUrl);
clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
clientContext.Credentials = new SharePointOnlineCredentials(userName, pwd);

new ThemeManager().DeployContosoThemeToWeb(clientContext, clientContext.Web, “MyTheme”,
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, “Files/Custom/mytheme.spcolor”),
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, “Files/Custom/mypic.jpg”),

new ThemeManager().SetThemeBasedOnName(clientContext, clientContext.Web, “MyTheme”);

Console.WriteLine(“Theme has been applied to the provided site successfully.”);

Do visit my other blogs on office365 below.


Add Webpart in a Page in Office 365 using CSOM

Apply Site Logo In Office 365 using CSOM Code

Set Alternate CSS URL in Office 365 using CSOM


Happy SharePointing Folks!! Hope it helps someone!!

Leave a Reply

Your email address will not be published. Required fields are marked *