Friday 18 October 2013

Get user Email ID from a sharepoint people picker field / column of a list

The below code works fine to get an Email ID from people picker field for an Item of a list.

        string userEmailID = GetUserEmail(spListItem, "PeoplePickerfieldName");

        public string GetUserEmail(SPListItem spListItem, string fieldName)
        {
            SPFieldUser spFieldUser = (SPFieldUser)spListItem.Fields[fieldName];
            SPFieldUserValue spFieldUserValue = (SPFieldUserValue)spFieldUser.GetFieldValue(spListItem[fieldName].ToString());
            return spFieldUserValue.User.Email;
        }



No comments:

Post a Comment

Total Pageviews