Question

I am using CAML to retrieve some sharepoint list items. On of the columns is a PeoplePicker control. How can I extract the email address from this column?

I know how to get the LookupValue and LookupID, but not the email.

FieldUserValue usvSM1 = i["Account"] as FieldUserValue;
Console.WriteLine(usvSM1.LookupValue);

Keep in mind that I'm programming against the client object model.

Thanks a lot!

Was it helpful?

Solution

Try this:

var user = web.SiteUsers.GetById(usvSM1.LookupId);

context.Load(user);
context.ExecuteQuery();

Console.WriteLine(user.Email);

EDIT: Web.SiteUsers property is available only SharePoint 2013 client object model.

Second way you can try to get user:

var user = web.EnsureUser(usvSM1.LookupValue);

context.Load(user);
context.ExecuteQuery();

Console.WriteLine(user.Email);

OTHER TIPS

        FieldUserValue [] fTo = oListItem["People picker field name"]  as FieldUserValue[];
            var userTo = clientContext.Web.SiteUsers.GetById(fTo[0].LookupId);
            clientContext.Load(userTo);
            clientContext.ExecuteQuery();
            headers.To.Add(userTo.Email);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top