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.
He is Consultant for SharePoint Solutions for collaboration, communication and business processes. He provides his customers applications based on standard features as well as development or combining the power of several microsoft tools like Dynamics CRM. In his free time he tries to collect tipps and worthy experience in this blog.