Question: On Windows XP in an Active directory environment - what is the easiest way for me to query a user's email address from AD given their username on the command line. 

(Assuming I know where it is kept normally in tree). 

(I know about net user *loginname* /domain but I just want the email address element back.)

Answer: 
If the email that you want is also the User Principal Name, you can get it with

```
whoami /upn

```

However, this only works to get the email of the current user, not any user as the question originally postulated.
I don't know it's matched to the thread starter mean or not. But I just find a solution of my existing problem that was already solved after browse this thread. *Finding USER LOGIN ID based on KNOWN MAIL ADDRESS*. :)

```
C:\Users\MrCMD>for /f "delims=" %u in ('type salesforce-uid-mail-address.txt') do @dsquery.exe * -filter "(&(objectClass=user)(!(objectClass=computer)(mail=%u)))">>"salesforce-uid-cn.txt"
┌─────────────────────────────────────┐
│ Executed Wed 07/10/2013  8:29:55.05 │ As [MrCMD]
└─────────────────────────────────────┘
C:\Users\MrCMD>for /f "delims=" %u in ('type salesforce-uid-cn.txt') do @dsget.exe user %u -samid -l|find "samid" /i>>"salesforce-uid-samid.txt"
┌─────────────────────────────────────┐
│ Executed Wed 07/10/2013  8:31:56.40 │ As [MrCMD]
└─────────────────────────────────────┘

```

File [**salesforce-uid-mail-address.txt**] contains list of e-mail addresses. File [**salesforce-uid-cn.txt**] contains "complete CN with path". And file [**salesforce-uid-samid.txt**] contains "found SAMID" alias "user login name". **That's all folks.** Any ideas for improvement are welcome. :)