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?

  • 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

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);
| improve this answer | |

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.

| 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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