Search code examples
c#.netexchange-server

How to Get the Current User's Email Address in a Windows Office Network Using C#


I am working on a C# application and need to retrieve the email address of the current user. The user is part of a typical Windows office network. I am looking for a way to get this information programmatically.

Here is a rough idea of what I am aiming for:

string emailAddress = CurrentUser.EmailAddress;

Could someone guide me on how to achieve this? What APIs or methods should I use?


Solution

  • If you're behind a Windows domain, you could always grab their email address out of Active Directory.

    See Javier G. Lozano's example in his tutorial, "Querying Active Directory for User Emails".