Monday, August 15, 2011

How to use SharePoint Client Object Model to get User Information by User Lookup ID

protected string getUserEmail(int lookupid)
{
    String Useremail = string.Empty; 
 
    try
    {
        using (ClientContext clientContext = new ClientContext(siteUrl))
        {
            Microsoft.SharePoint.Client.ListItem userInfo = clientContext.Web.SiteUserInfoList.GetItemById(lookupid);
            clientContext.Load(userInfo);
            clientContext.ExecuteQuery();
            Useremail = userInfo["EMail"].ToString();
        } 
 
    }
    catch (Exception ex)
    {
        // TODO: // handle the error             
    } 
 
    return Useremail;
}
Post a Comment