I am creating a SharePoint 2010 workflow in Visual Studio 2012. I would like to use colors and fonts from the site's theme to style the emails. Because the customers may change the site theme, I'd like to pull the information from the site's active theme rather than hard-coding the values into the email.

How do I access the site's theme and retrieve the font names, sizes, and colors of various theme elements?

1 Answer 1


I eventually figured out that I could retrieve the ThmxTheme object from the current site. As long as the customer was using a theme, any theme, it would exist and have the information I needed. However, if the customer used the "default" or no theme, this would be null, in which case I just guessed at the appropriate style elements.

    private string _emailCSS = null;
    private string EmailCSS
            if (_emailCSS == null)
                ThmxTheme theme;
                string themeForWeb = ThmxTheme.GetThemeUrlForWeb(WorkflowProperties.Web);

                string fontFamily;
                string color;
                string backgroundColor;
                string accentColor;

                if (string.IsNullOrEmpty(themeForWeb))
                    // default values if site has no theme
                    fontFamily = "Verdana, sans-serif";
                    color = ColorTranslator.ToHtml(Color.Navy);
                    backgroundColor = ColorTranslator.ToHtml(Color.LightGray);
                    accentColor = ColorTranslator.ToHtml(Color.Blue);
                    // use theme colors for emails, if site has a theme
                    theme = ThmxTheme.Open(WorkflowProperties.Site, themeForWeb);
                    fontFamily = theme.MinorFont.LatinFont;
                    color = ColorTranslator.ToHtml(theme.DarkColor1.DefaultColor);
                    backgroundColor = ColorTranslator.ToHtml(theme.LightColor2.DefaultColor);
                    accentColor = ColorTranslator.ToHtml(theme.HyperlinkColor.DefaultColor);
                _emailCSS = string.Format(@"
    BODY {{
        font-size: small;
        font-family: {0};
        color: {1};
        background-color: {2};
    P {{
    .folio {{
        color: {3};

" , fontFamily , color , backgroundColor , accentColor ); } return _emailCSS; } }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.