title: Is it possible to get user email with loginname programmatically in sharepoint?
body: <p>I have a search function that returns the email for a user when I have the user's ID</p>
  
  <pre><code>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;
  }
  </code></pre>
  
  <p>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?</p>
  
  <p>Any help or links would be appreciated.</p>
  
  <p>Thanks in advance.</p>