Find ALL SMTP and smtp (Primary and secondary emails addresses from AD/exchange settings

  • Thread starter Thread starter FayazNaim
  • Start date Start date
F

FayazNaim

Guest
Hi All, I am trying to find find ALL SMTP and smtp (Primary and secondary emails addresses from AD/exchange settings. I can already pull the primary SMTP but the rest of the (lowercase/non-primary/secondary) email addresses are hard to pull. I event tried doing some searches or it but all seem to be talking about the primary and not an all inclusive retrieval of data.

using (PrincipalContext domainContext = new PrincipalContext(ContextType.Domain, domain))
{
using (UserPrincipal user = UserPrincipal.FindByIdentity(domainContext, username))
{
richTextBox2.AppendText(Convert.ToString("Full Name (in AD)= "+user + "\n"));
if ((user.EmailAddress == null) | (domain != "myDomain"))
{
richTextBox2.AppendText("No email address (...associated with this ID in this domain)\n\n");
}
else
{
richTextBox2.AppendText(user.EmailAddress + "\n\n");
}
}
}

Continue reading...
 
Back
Top