You can use sharepoint object model you can get the email id from login user name. I have created one method to get the email ID after passing the user first and last name.
I have used Microsoft Sharepoint SiteUserInfoList library, you can find all the imported user details in this list.
public string getEmail(string firstName,lastName) { string emailID = ""; try { SPListItemCollection spListItemColl = Site.RootWeb.SiteUserInfoList.Items; foreach (SPListItem item in spListItemColl) { //Checking for first and last name if (item["FirstName"] != null && (firstName.ToUpper() == item["FirstName"].ToString().ToUpper()) && item["LastName"] != null && (lastName.ToUpper() == item["LastName"].ToString().ToUpper()) && item["EMail"] != null) { emailID = item["EMail"].ToString(); break; } } } catch (Exception ex) { throw ex; } return emailID; }
Usage example,
string testName=getEmail("Sandesh","MM");
Same way you can customize above method to get the email id from login username. If you found any good approaches just write down, it may helps to someone.
Enjoy coding 🙂
Sandesh
Similar Topics:
- Microsoft Sharepoint updating Author-Created By or Editor field programmatically
- Client Object Model and Linq to Sharepoint implementation
- Microsoft Sharepoint SystemUpdate and Update using object model
- Infopath form to HTML using csharp
- SharePoint Developer Interview Questions and Answers
- Microsoft Sharepoint persisting webpart property values
- SPDisposeCheck – Sharepoint Tools to check memory leaks
- List enhancements in SharePoint 2010
- How to find the SharePoint 2007 version
- More about SharePoint Custom page and Application Page