Trying to get the e-mail adress of a user for whom you only have the display name like surname and name, you can get the user information by using the SPUtility function ResolvePrincipal. It’s quite easy but you have to ensure that
- the user has access to the site in any kind
- you check if “pInfo” in this example is not null before using it in code
SPPrincipalInfo pinfo = SPUtility.ResolvePrincipal(web, "John Smith", SPPrincipalType.User, SPPrincipalSource.All, web.AllUsers, false);
It’s worthy to check what other function SPUtility provides before writing your own methods.
..:: I LIKE SHAREPOINT ::..The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.