I have a search function that returns the email for a user when I have the user's ID
private string getUserEmail(string userID)
{
string userEmail = null;
SPGroupCollection collGroups = SPContext.Current.Web.Groups;
int userIDint = Convert.ToInt32(userID);
foreach (SPGroup oGroup in collGroups)
{
userEmail = oGroup.Users.GetByID(userIDint).Email.ToString();
}
return userEmail;
}
with Users I can do either GetByID or GetByEmail but what should I do if I have the domain name such as MyDomain\myUsername and want the email for that user?
Any help or links would be appreciated.
Thanks in advance.
http://msdn.microsoft.com/en-us/library/ms414398.aspx
SPContext.Current.Web.AllUsers["loginname"].Email
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.ensureuser.aspx
SPContext.Current.Web.EnsureUser("loginname").Email
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With