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 am creating a custom workflow which gets activated whenever some data is entered in a particular list. One of the field in this list is a column for Email ID of the a user( not necessarily the logged in user).

Based on this,I have to write a CAML query which selects the First Name based on the user's Email ID in SharePoint 2007. Is there a way to get rest of the user details from email id?

share|improve this question
    
What is the type of Email ID column? Is it just a plain Text or a User column? –  Janis Veinbergs Jan 19 '12 at 12:11
add comment

2 Answers

You can query SiteUserInfoList to retrieve user by email. With result of query you can find SPUser by id.

var web = SPContext.Current.Web;

SPQuery query       = new SPQuery();
query.Query         = "<Eq><FieldRef Name=\"EMail\" /><Value Type=\"Text\">sample@microsoft.com</Value></Eq>";
var items           = web.SiteUserInfoList.GetItems(query);
var user            = web.SiteUsers.GetByID(items[0].ID);
share|improve this answer
add comment

I believe you are trying to read from the same list with data from other columns. Please correct me if I am wrong.

In that case, try using the U2U Caml Query builder to test your CAML queries.

Install the CAML builder, point it to your site, read the particular list. You can give filters and order the results accordingly.

share|improve this answer
    
Sorry if the details are not clear. The problem is that email id is entered by people picker( from AD). When creating a new item for a list, theres a column for email id ( which gets picked from AD). Based on this emial id i need to retrieve the rest of the details for the user using CAML query. Is it possible? –  Thomas Mathew Jan 19 '12 at 11:34
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.