Get current user's email address in .NET

前端 未结 4 1594
面向向阳花
面向向阳花 2021-02-02 07:24

I would like to know the email address of the user (assuming she\'s in a typical Windows office network). This is in a C# application. Perhaps something to the effect of

4条回答
  •  暖寄归人
    2021-02-02 07:59

    // Simply by using UserPrincipal
    // Include the namespace - System.DirectoryServices
    
    using DS = System.DirectoryServices;
    string CurrUsrEMail = string.Empty;
    CurrUsrEMail = DS.AccountManagement.UserPrincipal.Current.EmailAddress;
    

提交回复
热议问题