Wednesday, October 7, 2015

Get user Email ID from a sharepoint people picker field / column of SharePoint 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;
        }


The above code from the below URL:

http://techiescode.blogspot.com/2013/10/get-user-email-id-from-sharepoint.html


1 comment: