I have a custom phone list that was populated from an Excel spreadsheet. I have to add the email address to this list in SharePoint. How do I query Active Directory for the correct email address for each person?
Does the phone list contain the users account as a field or do you have any other person/group fields defined?
If so, I'd probably create a person/group column set to display email address. Then you just add the person's AD account into the field and it will display their email. You could automate this then by creating a workflow to automatically update that field to the account field on creation.
If the person's phone number is one of the attributes that SharePoint is configured to pull from Active Directory then you can query that information from their user profile. This is not an option if using WSS, however. (sample code)
You could write a console app that would do the AD lookup directly and then populate the field in the list. (sample code)
You could write VBA code in the original Excel file that would do the lookup and popupulate the phone number field prior to import. (Sample code)