Thursday, September 24, 2009

How to Update User Profile using C#

using (SPSite site = new SPSite(“http://portal”))

{
Microsoft.Office.Server.ServerContext Context = ServerContext.GetContext(site);
Microsoft.Office.Server.UserProfiles.UserProfileManager Mngr = new UserProfileManager(Context);
Microsoft.Office.Server.UserProfiles.UserProfile Profile = Mngr.GetUserProfile(“litwareinc\ashishk”);
System.Console.Write(Profile[“Title”].Value.ToString());
Profile[“Title”].Value = “New Title”;
Profile.Commit();
}


Bingo, here ashishk Title is updated with "New Title"

Tuesday, September 22, 2009

How to retrieve account names from UserProfile

It is quite difficult to get accountnames from userprofile database. Using SDK, you can get the account by following example

using (SPSite site = new SPSite(http://portal/))
{
        ServerContext context = ServerContext.GetContext(site);
        UserProfileManager profileManager = new UserProfileManager(context);

        foreach (UserProfile profile in profileManager)
       {
             Console.WriteLine(profile[PropertyConstants.AccountName]);
       }
}

Saturday, August 15, 2009

Data View conditional formatting using SharePoint Designer

Following article demonstrates how to use SharePoint Designer 2007 conditional formatting to format items in a SharePoint (MOSS 2007) list based on item metadata.

http://blog-sharepoint.blogspot.com/2009/05/data-view-conditional-formatting-using.html

Tuesday, July 28, 2009

How to send HTML email from Sharepoint with CC/BCC

public static void SendEmail(SPWeb web, string toEmail, string ccEmail,

string bccEmail,
string subject, string body)
{
   if (!string.IsNullOrEmpty(toEmail))
  {
     StringDictionary headers = new StringDictionary
     {
        {"to", toEmail},
        {"cc", ccEmail},
        {"bcc", bccEmail},
        {"subject", subject},
        {"content-type", "text/html"}
     };
     SPUtility.SendEmail(web, headers, body);
   }
}

Sunday, July 19, 2009

Interesting articles on various blogspot

I found various intereting articles on various blog as mentioned below