title: How to get a user's e-mail address from Active Directory?
body: <p>I am trying to get a user's email address in AD without success.</p>
  
  <pre><code>String account = userAccount.Replace(@"Domain\", "");
  DirectoryEntry entry = new DirectoryEntry();
  
  try {
      DirectorySearcher search = new DirectorySearcher(entry);
  
      search.PropertiesToLoad.Add("mail");  // e-mail addressead
  
      SearchResult result = search.FindOne();
      if (result != null) {
          return result.Properties["mail"][0].ToString();
      } else {
          return "Unknown User";
      }
  } catch (Exception ex) {
      return ex.Message;
  }
  </code></pre>
  
  <p>Can anyone see the issue or point in the right direction?</p>