I need to iterate through all the profiles existed in SharePoint and read the profiles property called "workemail". I followed below link, but no use. Getting error at "uniqueId" in the code.
Tried below code as well
SPSite site = new SPSite(strUrl); // strUrl = I am mentioning MySite site collection URL here. Like ex: http://servername:1111/
ServerContext context = ServerContext.GetContext(site);
UserProfileManager usrPrfMngr = new UserProfileManager(context);
foreach(UserProfile profile in usrPrfMngr)
strEmail = profile["WorkEmail"].ToString();
The above code is only reading the property of current logged on user. It is not iterating through all the profiles. After reading the current user property it is throwing an exception at foreach loop saying "Object reference is not set to
Any help would be appreciated.
View Complete Post