Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a piece of code which gets the email address of a SPUser object. The email property is empty. Where I can fill the email address of this user? Is it in SharePoint or somewhere in AD? I dont have a sync connection to AD!

SPFieldUser userField = (SPFieldUser)currentItem.Fields.GetField(Constants.Fields.FIELD_CLIENT);
            SPFieldUserValue fieldValue = (SPFieldUserValue)userField.GetFieldValue(Convert.ToString(currentItem[Constants.Fields.FIELD_CLIENT]));
            SPUser assignedToUser = fieldValue.User;


string clientEmail = assignedToUser.Email;

// dosomething
share|improve this question
add comment

2 Answers

1.Assuming you do not have User Profiles Synchronized , there are no email address for the users You need to create a UserProfile Synchronization Service ,so that all the users are sync/imported to sharepoint. Later you can user profile code and get the relevant users information.

OR

2.ELSE If you are not using/configuring User Profile Service anytime .You will need to have your design changed (where a user enters his/her email id) or some other mechanism.

share|improve this answer
add comment

You will need to actually request the user profile for that user so you can read all the properties for that user (including email). This question has some samples of how to do that in code: How to get user profile property value when privacy for property set to "Private" (only me)

share|improve this answer
    
Since there is no User Profile servive . How will this work ? –  Nikhil Mar 21 at 15:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.